aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoralon@honor <none@none>2010-09-05 16:30:28 -0700
committeralon@honor <none@none>2010-09-05 16:30:28 -0700
commit3e6c745b828932f237e472c484bb2ac2abfb8e3e (patch)
treeb53e663c5d4c644ce3cfc02a73e49efabaa9db3b /src
parent33059350a3a86885dd4c73f3219162ec54d4c0d5 (diff)
optimize makesplitter
Diffstat (limited to 'src')
-rw-r--r--src/enzymatic.js5
-rw-r--r--src/parser.js21
2 files changed, 16 insertions, 10 deletions
diff --git a/src/enzymatic.js b/src/enzymatic.js
index 09c8cfc4..c2c7979e 100644
--- a/src/enzymatic.js
+++ b/src/enzymatic.js
@@ -39,9 +39,9 @@ Substrate.prototype = {
var startTime = Date.now();
var midTime = startTime;
var that = this;
- function midComment() {
+ function midComment(force) {
var curr = Date.now();
- if (curr - midTime > 1000) {
+ if (curr - midTime > 1000 || force) {
print('// Working on ' + that.name_ + ', so far ' + ((curr-startTime)/1000).toString().substr(0,10) + ' seconds. Have ' + that.items.length + ' items.');
midTime = curr;
}
@@ -119,6 +119,7 @@ Substrate.prototype = {
delete item.__uid__;
}
});
+ //midComment(true);
}
}
if (this.items.length === 0) {
diff --git a/src/parser.js b/src/parser.js
index beb66ac9..491e31f5 100644
--- a/src/parser.js
+++ b/src/parser.js
@@ -141,15 +141,20 @@ function splitTokenList(tokens) {
function makeSplitter(parentSlot, parentSlotValue, parentUnrequiredSlot, childSlot, copySlots) {
return {
selectItem: function(item) { return item[parentSlot] == parentSlotValue && !item[parentUnrequiredSlot] && item[childSlot] !== null },
- processItem: function(parent) {
- var child = parent[childSlot];
- parent[childSlot] = null;
- child.parentUid = parent.__uid__;
- child.parentSlot = childSlot;
- child.lineNum = parent.lineNum; // Debugging
+ process: function(parents) {
if (!copySlots) copySlots = [];
- copySlots.forEach(function(slot) { child[slot] = parent[slot] });
- return [parent, child];
+ var ret = parents.slice(0);
+ for (var i = 0; i < parents.length; i++) {
+ var parent = parents[i];
+ var child = parent[childSlot];
+ parent[childSlot] = null;
+ child.parentUid = parent.__uid__;
+ child.parentSlot = childSlot;
+ child.lineNum = parent.lineNum; // Debugging
+ copySlots.forEach(function(slot) { child[slot] = parent[slot] });
+ ret.push(child);
+ }
+ return ret;
},
};
}