@@ -6,7 +6,7 @@ import properties from './lib/properties.js';
6
6
import ContextTree from './lib/context-tree.js' ;
7
7
8
8
const PLUGIN_DISPATCH_LIMIT = 100 ;
9
- const TRAVERSE_LIMIT = 1000 ;
9
+ const TRAVERSE_LIMIT = 3000 ;
10
10
const noop = ( ) => { } ;
11
11
12
12
class SpecMap {
@@ -40,7 +40,6 @@ class SpecMap {
40
40
getInstance : ( ) => this ,
41
41
} ) ,
42
42
allowMetaPatches : false ,
43
- currentTraverseCount : 0 ,
44
43
} ,
45
44
opts
46
45
) ;
@@ -72,7 +71,6 @@ class SpecMap {
72
71
73
72
wrapPlugin ( plugin , name ) {
74
73
const { pathDiscriminator } = this ;
75
- const that = this ;
76
74
let ctx = null ;
77
75
let fn ;
78
76
@@ -107,16 +105,15 @@ class SpecMap {
107
105
const refCache = { } ;
108
106
109
107
// eslint-disable-next-line no-restricted-syntax
110
- for ( const patch of patches . filter ( lib . isAdditiveMutation ) ) {
111
- if ( that . currentTraverseCount < TRAVERSE_LIMIT ) {
108
+ for ( const [ i , patch ] of patches . filter ( lib . isAdditiveMutation ) . entries ( ) ) {
109
+ if ( i < TRAVERSE_LIMIT ) {
112
110
yield * traverse ( patch . value , patch . path , patch ) ;
113
111
} else {
114
112
return ;
115
113
}
116
114
}
117
115
118
116
function * traverse ( obj , path , patch ) {
119
- that . currentTraverseCount += 1 ;
120
117
if ( ! lib . isObject ( obj ) ) {
121
118
if ( pluginObj . key === path [ path . length - 1 ] ) {
122
119
yield pluginObj . plugin ( obj , pluginObj . key , path , specmap ) ;
@@ -142,11 +139,7 @@ class SpecMap {
142
139
if ( specmap . allowMetaPatches && objRef ) {
143
140
refCache [ objRef ] = true ;
144
141
}
145
- if ( that . currentTraverseCount < TRAVERSE_LIMIT ) {
146
- yield * traverse ( val , updatedPath , patch ) ;
147
- } else {
148
- return ;
149
- }
142
+ yield * traverse ( val , updatedPath , patch ) ;
150
143
}
151
144
}
152
145
@@ -325,8 +318,6 @@ class SpecMap {
325
318
const that = this ;
326
319
const plugin = this . nextPlugin ( ) ;
327
320
328
- that . currentTraverseCount = 0 ;
329
-
330
321
if ( ! plugin ) {
331
322
const nextPromise = this . nextPromisedPatch ( ) ;
332
323
if ( nextPromise ) {
0 commit comments