Mercurial > browser-couch
changeset 31:8cb658549511
Optimized emit() a bit, as it's taking up 60% of execution time on the big test.
author | Atul Varma <varmaa@toolness.com> |
---|---|
date | Mon, 13 Apr 2009 16:55:12 -0700 |
parents | e136ddfc6175 |
children | 68fa98bcc9b5 |
files | browser-couch.js |
diffstat | 1 files changed, 5 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/browser-couch.js Mon Apr 13 16:38:31 2009 -0700 +++ b/browser-couch.js Mon Apr 13 16:55:12 2009 -0700 @@ -300,12 +300,13 @@ // TODO: This assumes that the key will always be // an indexable value. We may have to hash the value, // though, if it's e.g. an Object. - if (!(key in mapDict)) { + var item = mapDict[key]; + if (!item) { mapKeys.push(key); - mapDict[key] = {keys: [], values: []}; + item = mapDict[key] = {keys: [], values: []}; } - mapDict[key].keys.push([key, currDoc.id]); - mapDict[key].values.push(value); + item.keys.push([key, currDoc.id]); + item.values.push(value); } // Maximum number of items to process before giving the UI a chance