Skip to content

Commit c0511d6

Browse files
Resume warming up a partially warmed up index cache
Instead of recomputing the earlier ones
1 parent 469a6ef commit c0511d6

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

lib/SymbolTree.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,12 @@ class SymbolTree {
497497
index = 0;
498498
let object = parentNode.first;
499499

500+
if (parentNode.childIndexCachedUpTo) {
501+
const cachedUpToNode = this._node(parentNode.childIndexCachedUpTo);
502+
object = cachedUpToNode.next;
503+
index = cachedUpToNode.getCachedIndex(parentNode) + 1;
504+
}
505+
500506
while (object) {
501507
const node = this._node(object);
502508
node.setCachedIndex(parentNode, index);
@@ -509,6 +515,8 @@ class SymbolTree {
509515
object = node.next;
510516
}
511517

518+
parentNode.childIndexCachedUpTo = child;
519+
512520
return index;
513521
}
514522

lib/SymbolTreeNode.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ module.exports = class SymbolTreeNode {
1111

1212
/** This value is incremented anytime a children is added or removed */
1313
this.childrenVersion = 0;
14+
/** The last child object which has a cached index */
15+
this.childIndexCachedUpTo = null;
1416

1517
/** This value represents the cached node index, as long as
1618
* cachedIndexVersion matches with the childrenVersion of the parent */
@@ -30,6 +32,7 @@ module.exports = class SymbolTreeNode {
3032
/* jshint -W016 */
3133
// integer wrap around
3234
this.childrenVersion = (this.childrenVersion + 1) & 0xFFFFFFFF;
35+
this.childIndexCachedUpTo = null;
3336
}
3437

3538
getCachedIndex(parentNode) {

0 commit comments

Comments
 (0)