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 {
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
Original file line number Diff line number Diff 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 ) {
You can’t perform that action at this time.
0 commit comments