diff options
author | Stefano J. Attardi <stefano@attardi.org> | 2011-02-28 17:00:14 -0500 |
---|---|---|
committer | Paul J. Davis <paul.joseph.davis@gmail.com> | 2013-03-20 06:02:47 -0500 |
commit | 574555be3b0ee2fe07d4b7c5b49af3227d15acdc (patch) | |
tree | 98476c0e773ba6ed2f5702012da8a7a50be01078 /share | |
parent | 286b5981ced2b768489d2a96d8f4dede004e5049 (diff) | |
download | couchdb-574555be3b0ee2fe07d4b7c5b49af3227d15acdc.tar.gz |
Faster maps by delaying JSON serialization, skipping string concatenation, and better looping.
Diffstat (limited to 'share')
-rw-r--r-- | share/server/views.js | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/share/server/views.js b/share/server/views.js index 38feb4014..646aac80d 100644 --- a/share/server/views.js +++ b/share/server/views.js @@ -108,19 +108,19 @@ var Views = (function() { Couch.recursivelySeal(doc); var buf = []; - for (var i = 0; i < State.funs.length; i++) { + for (var i = 0, l = State.funs.length; i < l; i++) { map_results = []; try { State.funs[i](doc); - buf.push(Couch.toJSON(map_results)); + buf.push(map_results); } catch (err) { handleViewError(err, doc); // If the error is not fatal, we treat the doc as if it // did not emit anything, by buffering an empty array. - buf.push("[]"); + buf.push([]); } } - print("[" + buf.join(", ") + "]"); + print(JSON.stringify(buf)); } }; })(); |