Permalink
Browse files

Using `while` instead of `for` loop when utilizing node

  • Loading branch information...
1 parent df0db33 commit d5ef18cd8d9dac5b331fb297eca9b3a6b9b5cb87 @bemson committed Feb 23, 2014
Showing with 8 additions and 3 deletions.
  1. +8 −3 src/salt.js
View
@@ -1569,7 +1569,8 @@
node.reds = [];
// run core tags
- for (j = 0; j < coreTagKeyCount; j++) {
+ j = coreTagKeyCount;
+ while (j--) {
tagName = coreTagKeys[j];
coreTags[tagName](tagName, node.attrs.hasOwnProperty(tagName), node.attrs, node, parentNode, pkg, i);
}
@@ -1582,9 +1583,13 @@
}
// run post core tags for each node
- for (i = 0; i < nodeCount; i++) {
+ i = nodeCount;
+ // order matters less on cleanup
+ while (i--) {
node = nodes[i];
- for (j = 0; j < corePostTagKeyCount; j++) {
+ parentNode = nodes[node.parentIndex];
+ j = corePostTagKeyCount;
+ while (j--) {
tagName = corePostTagKeys[j];
corePostTags[tagName](tagName, node.attrs.hasOwnProperty(tagName), node.attrs, node, parentNode, pkg, i);
}

0 comments on commit d5ef18c

Please sign in to comment.