File tree Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -497,6 +497,12 @@ class SymbolTree {
497
497
index = 0 ;
498
498
let object = parentNode . first ;
499
499
500
+ if ( parentNode . childIndexCachedUpTo ) {
501
+ const cachedUpToNode = this . _node ( parentNode . childIndexCachedUpTo ) ;
502
+ object = cachedUpToNode . next ;
503
+ index = cachedUpToNode . getCachedIndex ( parentNode ) + 1 ;
504
+ }
505
+
500
506
while ( object ) {
501
507
const node = this . _node ( object ) ;
502
508
node . setCachedIndex ( parentNode , index ) ;
@@ -509,6 +515,8 @@ class SymbolTree {
509
515
object = node . next ;
510
516
}
511
517
518
+ parentNode . childIndexCachedUpTo = child ;
519
+
512
520
return index ;
513
521
}
514
522
Original file line number Diff line number Diff line change @@ -11,6 +11,8 @@ module.exports = class SymbolTreeNode {
11
11
12
12
/** This value is incremented anytime a children is added or removed */
13
13
this . childrenVersion = 0 ;
14
+ /** The last child object which has a cached index */
15
+ this . childIndexCachedUpTo = null ;
14
16
15
17
/** This value represents the cached node index, as long as
16
18
* cachedIndexVersion matches with the childrenVersion of the parent */
@@ -30,6 +32,7 @@ module.exports = class SymbolTreeNode {
30
32
/* jshint -W016 */
31
33
// integer wrap around
32
34
this . childrenVersion = ( this . childrenVersion + 1 ) & 0xFFFFFFFF ;
35
+ this . childIndexCachedUpTo = null ;
33
36
}
34
37
35
38
getCachedIndex ( parentNode ) {
You can’t perform that action at this time.
0 commit comments