@@ -14,11 +14,6 @@ import {
1414} from 'react-native/Libraries/ReactPrivate/ReactNativePrivateInterface' ;
1515import isArray from 'shared/isArray' ;
1616
17- import {
18- enableShallowPropDiffing ,
19- enableFastAddPropertiesInDiffing ,
20- } from 'shared/ReactFeatureFlags' ;
21-
2217import type { AttributeConfiguration } from './ReactNativeTypes' ;
2318
2419const emptyObject = { } ;
@@ -141,12 +136,12 @@ function diffNestedArrayProperty(
141136 ) ;
142137 }
143138 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 ) ;
150145 }
151146 return updatePayload ;
152147}
@@ -205,41 +200,6 @@ function diffNestedProperty(
205200 ) ;
206201}
207202
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-
243203/**
244204 * clearNestedProperty takes a single set of props and valid attributes. It
245205 * adds a null sentinel to the updatePayload, for each prop key.
@@ -349,7 +309,7 @@ function diffProperties(
349309 // Pattern match on: attributeConfig
350310 if ( typeof attributeConfig !== 'object' ) {
351311 // case: !Object is the default case
352- if ( enableShallowPropDiffing || defaultDiffer ( prevProp , nextProp ) ) {
312+ if ( defaultDiffer ( prevProp , nextProp ) ) {
353313 // a normal leaf has changed
354314 ( updatePayload || ( updatePayload = ( { } : { [ string ] : $FlowFixMe } ) ) ) [
355315 propKey
@@ -361,7 +321,6 @@ function diffProperties(
361321 ) {
362322 // case: CustomAttributeConfiguration
363323 const shouldUpdate =
364- enableShallowPropDiffing ||
365324 prevProp === undefined ||
366325 ( typeof attributeConfig . diff === 'function'
367326 ? attributeConfig . diff ( prevProp , nextProp )
@@ -452,15 +411,15 @@ function diffProperties(
452411 return updatePayload ;
453412}
454413
455- function fastAddProperties (
414+ function addNestedProperty (
456415 payload : null | Object ,
457416 props : Object ,
458417 validAttributes : AttributeConfiguration ,
459418) : null | Object {
460419 // Flatten nested style props.
461420 if ( isArray ( props ) ) {
462421 for ( let i = 0 ; i < props . length ; i ++ ) {
463- payload = fastAddProperties ( payload , props [ i ] , validAttributes ) ;
422+ payload = addNestedProperty ( payload , props [ i ] , validAttributes ) ;
464423 }
465424 return payload ;
466425 }
@@ -507,23 +466,12 @@ function fastAddProperties(
507466 continue ;
508467 }
509468
510- payload = fastAddProperties ( payload , prop , attributeConfig ) ;
469+ payload = addNestedProperty ( payload , prop , attributeConfig ) ;
511470 }
512471
513472 return payload ;
514473}
515474
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-
527475/**
528476 * clearProperties clears all the previous props by adding a null sentinel
529477 * to the payload for each valid key.
@@ -533,15 +481,14 @@ function clearProperties(
533481 prevProps : Object ,
534482 validAttributes : AttributeConfiguration ,
535483) : null | Object {
536- // TODO: Fast path
537484 return diffProperties ( updatePayload , prevProps , emptyObject , validAttributes ) ;
538485}
539486
540487export function create (
541488 props : Object ,
542489 validAttributes : AttributeConfiguration ,
543490) : null | Object {
544- return fastAddProperties ( null , props , validAttributes ) ;
491+ return addNestedProperty ( null , props , validAttributes ) ;
545492}
546493
547494export function diff (
0 commit comments