Skip to content

Commit a108cab

Browse files
javachemeta-codesync[bot]
authored andcommitted
Drop per-field enableCppPropsIteratorSetter ternaries from Props ctors
Summary: With `ConcreteComponentDescriptor::cloneProps` now dispatching to the iterator-setter path via the copy ctor (the prior diffs in the stack), the per-field `flag ? sourceProps.X : convertRawProp(...)` ternaries scattered across every Props copy ctor are dead in the flag-on path (copy ctor handles those fields directly) and redundant in the flag-off path (the runtime check inside the ctor is always false, since cloneProps already filtered the iterator-setter path out before invoking the 3-arg ctor). Strip the ternary wrapper from every Props .cpp file. Each initializer collapses from ```cpp field(ReactNativeFeatureFlags::enableCppPropsIteratorSetter() ? sourceProps.field : convertRawProp(ctx, rawProps, "field", sourceProps.field, default)) ``` to just ```cpp field(convertRawProp(ctx, rawProps, "field", sourceProps.field, default)) ``` Also strip: - `YogaStylableProps`: the inverted `if (!flag) { convertRawPropAliases(...); }` wrapper becomes unconditional. - `Props::initialize` (`Props.cpp`): the `nativeId` ternary collapses to the `convertRawProp` form. - `AccessibilityProps` (xplat + react-native-macos): the `if (flag) { copy } else { at()-based resolution }` block in the constructor body collapses to just the `at()`-based resolution — the same reasoning applies (flag-on path never reaches the 3-arg ctor). - Drop `<react/featureflags/ReactNativeFeatureFlags.h>` includes that are no longer referenced. 311 ternaries removed across 20 Props .cpp files (incl. the `third-party/react-native-macos/` mirror and `xplat/instagram/airwave/components/airwavescrollview/cpp/AirwaveScrollViewProps.cpp`). Side benefit: the classic path is now meaningfully cheaper because we no longer do `~30 × ReactNativeFeatureFlags::enableCppPropsIteratorSetter()` calls (each goes through `std::atomic<std::optional<bool>>::load()`) per `cloneProps` invocation per Props class. Changelog: [Internal] Differential Revision: D109583086
1 parent 2ab608b commit a108cab

12 files changed

Lines changed: 902 additions & 1359 deletions

File tree

packages/react-native/ReactCommon/react/renderer/components/image/ImageProps.cpp

Lines changed: 79 additions & 126 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8-
#include <react/featureflags/ReactNativeFeatureFlags.h>
98
#include <react/renderer/components/image/ImageProps.h>
109
#include <react/renderer/components/image/conversions.h>
1110
#include <react/renderer/core/propsConversions.h>
@@ -19,131 +18,85 @@ ImageProps::ImageProps(
1918
const RawProps& rawProps)
2019
: ViewProps(context, sourceProps, rawProps),
2120
sources(
22-
ReactNativeFeatureFlags::enableCppPropsIteratorSetter()
23-
? sourceProps.sources
24-
: convertRawProp(
25-
context,
26-
rawProps,
27-
"source",
28-
sourceProps.sources,
29-
{})),
30-
defaultSource(
31-
ReactNativeFeatureFlags::enableCppPropsIteratorSetter()
32-
? sourceProps.defaultSource
33-
: convertRawProp(
34-
context,
35-
rawProps,
36-
"defaultSource",
37-
sourceProps.defaultSource,
38-
{})),
39-
loadingIndicatorSource(
40-
ReactNativeFeatureFlags::enableCppPropsIteratorSetter()
41-
? sourceProps.loadingIndicatorSource
42-
: convertRawProp(
43-
context,
44-
rawProps,
45-
"loadingIndicatorSource",
46-
sourceProps.loadingIndicatorSource,
47-
{})),
48-
resizeMode(
49-
ReactNativeFeatureFlags::enableCppPropsIteratorSetter()
50-
? sourceProps.resizeMode
51-
: convertRawProp(
52-
context,
53-
rawProps,
54-
"resizeMode",
55-
sourceProps.resizeMode,
56-
ImageResizeMode::Stretch)),
57-
blurRadius(
58-
ReactNativeFeatureFlags::enableCppPropsIteratorSetter()
59-
? sourceProps.blurRadius
60-
: convertRawProp(
61-
context,
62-
rawProps,
63-
"blurRadius",
64-
sourceProps.blurRadius,
65-
{})),
66-
capInsets(
67-
ReactNativeFeatureFlags::enableCppPropsIteratorSetter()
68-
? sourceProps.capInsets
69-
: convertRawProp(
70-
context,
71-
rawProps,
72-
"capInsets",
73-
sourceProps.capInsets,
74-
{})),
75-
tintColor(
76-
ReactNativeFeatureFlags::enableCppPropsIteratorSetter()
77-
? sourceProps.tintColor
78-
: convertRawProp(
79-
context,
80-
rawProps,
81-
"tintColor",
82-
sourceProps.tintColor,
83-
{})),
84-
internal_analyticTag(
85-
ReactNativeFeatureFlags::enableCppPropsIteratorSetter()
86-
? sourceProps.internal_analyticTag
87-
: convertRawProp(
88-
context,
89-
rawProps,
90-
"internal_analyticTag",
91-
sourceProps.internal_analyticTag,
92-
{})),
93-
resizeMethod(
94-
ReactNativeFeatureFlags::enableCppPropsIteratorSetter()
95-
? sourceProps.resizeMethod
96-
: convertRawProp(
97-
context,
98-
rawProps,
99-
"resizeMethod",
100-
sourceProps.resizeMethod,
101-
{"auto"})),
102-
resizeMultiplier(
103-
ReactNativeFeatureFlags::enableCppPropsIteratorSetter()
104-
? sourceProps.resizeMultiplier
105-
: convertRawProp(
106-
context,
107-
rawProps,
108-
"resizeMultiplier",
109-
sourceProps.resizeMultiplier,
110-
1)),
111-
shouldNotifyLoadEvents(
112-
ReactNativeFeatureFlags::enableCppPropsIteratorSetter()
113-
? sourceProps.shouldNotifyLoadEvents
114-
: convertRawProp(
115-
context,
116-
rawProps,
117-
"shouldNotifyLoadEvents",
118-
sourceProps.shouldNotifyLoadEvents,
119-
{})),
120-
overlayColor(
121-
ReactNativeFeatureFlags::enableCppPropsIteratorSetter()
122-
? sourceProps.overlayColor
123-
: convertRawProp(
124-
context,
125-
rawProps,
126-
"overlayColor",
127-
sourceProps.overlayColor,
128-
{})),
129-
fadeDuration(
130-
ReactNativeFeatureFlags::enableCppPropsIteratorSetter()
131-
? sourceProps.fadeDuration
132-
: convertRawProp(
133-
context,
134-
rawProps,
135-
"fadeDuration",
136-
sourceProps.fadeDuration,
137-
{})),
138-
progressiveRenderingEnabled(
139-
ReactNativeFeatureFlags::enableCppPropsIteratorSetter()
140-
? sourceProps.progressiveRenderingEnabled
141-
: convertRawProp(
142-
context,
143-
rawProps,
144-
"progressiveRenderingEnabled",
145-
sourceProps.progressiveRenderingEnabled,
146-
{})) {}
21+
convertRawProp(context, rawProps, "source", sourceProps.sources, {})),
22+
defaultSource(convertRawProp(
23+
context,
24+
rawProps,
25+
"defaultSource",
26+
sourceProps.defaultSource,
27+
{})),
28+
loadingIndicatorSource(convertRawProp(
29+
context,
30+
rawProps,
31+
"loadingIndicatorSource",
32+
sourceProps.loadingIndicatorSource,
33+
{})),
34+
resizeMode(convertRawProp(
35+
context,
36+
rawProps,
37+
"resizeMode",
38+
sourceProps.resizeMode,
39+
ImageResizeMode::Stretch)),
40+
blurRadius(convertRawProp(
41+
context,
42+
rawProps,
43+
"blurRadius",
44+
sourceProps.blurRadius,
45+
{})),
46+
capInsets(convertRawProp(
47+
context,
48+
rawProps,
49+
"capInsets",
50+
sourceProps.capInsets,
51+
{})),
52+
tintColor(convertRawProp(
53+
context,
54+
rawProps,
55+
"tintColor",
56+
sourceProps.tintColor,
57+
{})),
58+
internal_analyticTag(convertRawProp(
59+
context,
60+
rawProps,
61+
"internal_analyticTag",
62+
sourceProps.internal_analyticTag,
63+
{})),
64+
resizeMethod(convertRawProp(
65+
context,
66+
rawProps,
67+
"resizeMethod",
68+
sourceProps.resizeMethod,
69+
{"auto"})),
70+
resizeMultiplier(convertRawProp(
71+
context,
72+
rawProps,
73+
"resizeMultiplier",
74+
sourceProps.resizeMultiplier,
75+
1)),
76+
shouldNotifyLoadEvents(convertRawProp(
77+
context,
78+
rawProps,
79+
"shouldNotifyLoadEvents",
80+
sourceProps.shouldNotifyLoadEvents,
81+
{})),
82+
overlayColor(convertRawProp(
83+
context,
84+
rawProps,
85+
"overlayColor",
86+
sourceProps.overlayColor,
87+
{})),
88+
fadeDuration(convertRawProp(
89+
context,
90+
rawProps,
91+
"fadeDuration",
92+
sourceProps.fadeDuration,
93+
{})),
94+
progressiveRenderingEnabled(convertRawProp(
95+
context,
96+
rawProps,
97+
"progressiveRenderingEnabled",
98+
sourceProps.progressiveRenderingEnabled,
99+
{})) {}
147100

148101
void ImageProps::setProp(
149102
const PropsParserContext& context,

0 commit comments

Comments
 (0)