@@ -14,11 +14,6 @@ import {
14
14
} from 'react-native/Libraries/ReactPrivate/ReactNativePrivateInterface' ;
15
15
import isArray from 'shared/isArray' ;
16
16
17
- import {
18
- enableShallowPropDiffing ,
19
- enableFastAddPropertiesInDiffing ,
20
- } from 'shared/ReactFeatureFlags' ;
21
-
22
17
import type { AttributeConfiguration } from './ReactNativeTypes' ;
23
18
24
19
const emptyObject = { } ;
@@ -141,12 +136,12 @@ function diffNestedArrayProperty(
141
136
) ;
142
137
}
143
138
for ( ; i < nextArray . length ; i ++ ) {
144
- // Add all remaining properties.
145
- updatePayload = addNestedProperty (
146
- updatePayload ,
147
- nextArray [ i ] ,
148
- validAttributes ,
149
- ) ;
139
+ // Add all remaining properties
140
+ const nextProp = nextArray [ i ] ;
141
+ if ( ! nextProp ) {
142
+ continue ;
143
+ }
144
+ updatePayload = addNestedProperty ( updatePayload , nextProp , validAttributes ) ;
150
145
}
151
146
return updatePayload ;
152
147
}
@@ -205,41 +200,6 @@ function diffNestedProperty(
205
200
) ;
206
201
}
207
202
208
- /**
209
- * addNestedProperty takes a single set of props and valid attribute
210
- * attribute configurations. It processes each prop and adds it to the
211
- * updatePayload.
212
- */
213
- function addNestedProperty (
214
- updatePayload : null | Object ,
215
- nextProp : NestedNode ,
216
- validAttributes : AttributeConfiguration ,
217
- ) : $FlowFixMe {
218
- if ( ! nextProp ) {
219
- return updatePayload ;
220
- }
221
-
222
- if ( enableFastAddPropertiesInDiffing ) {
223
- return fastAddProperties ( updatePayload , nextProp , validAttributes ) ;
224
- }
225
-
226
- if ( ! isArray ( nextProp ) ) {
227
- // Add each property of the leaf.
228
- return slowAddProperties ( updatePayload , nextProp , validAttributes ) ;
229
- }
230
-
231
- for ( let i = 0 ; i < nextProp . length ; i ++ ) {
232
- // Add all the properties of the array.
233
- updatePayload = addNestedProperty (
234
- updatePayload ,
235
- nextProp [ i ] ,
236
- validAttributes ,
237
- ) ;
238
- }
239
-
240
- return updatePayload ;
241
- }
242
-
243
203
/**
244
204
* clearNestedProperty takes a single set of props and valid attributes. It
245
205
* adds a null sentinel to the updatePayload, for each prop key.
@@ -349,7 +309,7 @@ function diffProperties(
349
309
// Pattern match on: attributeConfig
350
310
if ( typeof attributeConfig !== 'object' ) {
351
311
// case: !Object is the default case
352
- if ( enableShallowPropDiffing || defaultDiffer ( prevProp , nextProp ) ) {
312
+ if ( defaultDiffer ( prevProp , nextProp ) ) {
353
313
// a normal leaf has changed
354
314
( updatePayload || ( updatePayload = ( { } : { [ string ] : $FlowFixMe } ) ) ) [
355
315
propKey
@@ -361,7 +321,6 @@ function diffProperties(
361
321
) {
362
322
// case: CustomAttributeConfiguration
363
323
const shouldUpdate =
364
- enableShallowPropDiffing ||
365
324
prevProp === undefined ||
366
325
( typeof attributeConfig . diff === 'function'
367
326
? attributeConfig . diff ( prevProp , nextProp )
@@ -452,15 +411,15 @@ function diffProperties(
452
411
return updatePayload ;
453
412
}
454
413
455
- function fastAddProperties (
414
+ function addNestedProperty (
456
415
payload : null | Object ,
457
416
props : Object ,
458
417
validAttributes : AttributeConfiguration ,
459
418
) : null | Object {
460
419
// Flatten nested style props.
461
420
if ( isArray ( props ) ) {
462
421
for ( let i = 0 ; i < props . length ; i ++ ) {
463
- payload = fastAddProperties ( payload , props [ i ] , validAttributes ) ;
422
+ payload = addNestedProperty ( payload , props [ i ] , validAttributes ) ;
464
423
}
465
424
return payload ;
466
425
}
@@ -507,23 +466,12 @@ function fastAddProperties(
507
466
continue ;
508
467
}
509
468
510
- payload = fastAddProperties ( payload , prop , attributeConfig ) ;
469
+ payload = addNestedProperty ( payload , prop , attributeConfig ) ;
511
470
}
512
471
513
472
return payload ;
514
473
}
515
474
516
- /**
517
- * addProperties adds all the valid props to the payload after being processed.
518
- */
519
- function slowAddProperties (
520
- updatePayload : null | Object ,
521
- props : Object ,
522
- validAttributes : AttributeConfiguration ,
523
- ) : null | Object {
524
- return diffProperties ( updatePayload , emptyObject , props , validAttributes ) ;
525
- }
526
-
527
475
/**
528
476
* clearProperties clears all the previous props by adding a null sentinel
529
477
* to the payload for each valid key.
@@ -533,15 +481,14 @@ function clearProperties(
533
481
prevProps : Object ,
534
482
validAttributes : AttributeConfiguration ,
535
483
) : null | Object {
536
- // TODO: Fast path
537
484
return diffProperties ( updatePayload , prevProps , emptyObject , validAttributes ) ;
538
485
}
539
486
540
487
export function create (
541
488
props : Object ,
542
489
validAttributes : AttributeConfiguration ,
543
490
) : null | Object {
544
- return fastAddProperties ( null , props , validAttributes ) ;
491
+ return addNestedProperty ( null , props , validAttributes ) ;
545
492
}
546
493
547
494
export function diff (
0 commit comments