@@ -45,23 +45,23 @@ const RawValue* RawPropsParser::at(
45
45
return nullptr ;
46
46
}
47
47
48
- // Normally, keys are looked up in-order. For performance we can simply
49
- // increment this key counter, and if the key is equal to the key at the next
50
- // index, there's no need to do any lookups. However, it's possible for keys
51
- // to be accessed out-of-order or multiple times, in which case we start
52
- // searching again from index 0.
53
- // To prevent infinite loops (which can occur if you look up a key that
54
- // doesn't exist) we keep track of whether or not we've already looped around,
55
- // and log and return nullptr if so. However, we ONLY do this in debug mode,
56
- // where you're more likely to look up a nonexistent key as part of debugging.
57
- // You can (and must) ensure infinite loops are not possible in production by:
58
- // (1) constructing all props objects without conditionals, or (2) if there
59
- // are conditionals, ensure that in the parsing setup case, the Props
60
- // constructor will access _all_ possible props. To ensure this performance
61
- // optimization is utilized, always access props in the same order every time.
62
- // This is trivial if you have a simple Props constructor, but difficult or
63
- // impossible if you have a shared sub-prop Struct that is used by multiple
64
- // parent Props.
48
+ // Normally, keys are looked up in-order. For performance we can simply
49
+ // increment this key counter, and if the key is equal to the key at the next
50
+ // index, there's no need to do any lookups. However, it's possible for keys
51
+ // to be accessed out-of-order or multiple times, in which case we start
52
+ // searching again from index 0.
53
+ // To prevent infinite loops (which can occur if you look up a key that
54
+ // doesn't exist) we keep track of whether or not we've already looped around,
55
+ // and log and return nullptr if so. However, we ONLY do this in debug mode,
56
+ // where you're more likely to look up a nonexistent key as part of debugging.
57
+ // You can (and must) ensure infinite loops are not possible in production by:
58
+ // (1) constructing all props objects without conditionals, or (2) if there
59
+ // are conditionals, ensure that in the parsing setup case, the Props
60
+ // constructor will access _all_ possible props. To ensure this performance
61
+ // optimization is utilized, always access props in the same order every time.
62
+ // This is trivial if you have a simple Props constructor, but difficult or
63
+ // impossible if you have a shared sub-prop Struct that is used by multiple
64
+ // parent Props.
65
65
#ifdef REACT_NATIVE_DEBUG
66
66
bool resetLoop = false ;
67
67
#endif
@@ -168,57 +168,4 @@ void RawPropsParser::preparse(const RawProps& rawProps) const noexcept {
168
168
}
169
169
}
170
170
171
- /* *
172
- * To be used by RawProps only. Value iterator functions.
173
- */
174
- void RawPropsParser::iterateOverValues (
175
- const RawProps& rawProps,
176
- const std::function<
177
- void (RawPropsPropNameHash, const char *, const RawValue&)>& visit)
178
- const {
179
- switch (rawProps.mode_ ) {
180
- case RawProps::Mode::Empty:
181
- return ;
182
-
183
- case RawProps::Mode::JSI: {
184
- auto & runtime = *rawProps.runtime_ ;
185
- if (!rawProps.value_ .isObject ()) {
186
- LOG (ERROR) << " Preparse props: rawProps value is not object" ;
187
- }
188
- react_native_assert (rawProps.value_ .isObject ());
189
- auto object = rawProps.value_ .asObject (runtime);
190
-
191
- auto names = object.getPropertyNames (runtime);
192
- auto count = names.size (runtime);
193
-
194
- for (size_t i = 0 ; i < count; i++) {
195
- auto nameValue = names.getValueAtIndex (runtime, i).getString (runtime);
196
- auto value = object.getProperty (runtime, nameValue);
197
-
198
- auto name = nameValue.utf8 (runtime);
199
-
200
- auto nameHash = RAW_PROPS_KEY_HASH (name);
201
- auto rawValue = RawValue (jsi::dynamicFromValue (runtime, value));
202
-
203
- visit (nameHash, name.c_str (), rawValue);
204
- }
205
-
206
- break ;
207
- }
208
-
209
- case RawProps::Mode::Dynamic: {
210
- const auto & dynamic = rawProps.dynamic_ ;
211
-
212
- for (const auto & pair : dynamic.items ()) {
213
- auto name = pair.first .getString ();
214
-
215
- auto nameHash = RAW_PROPS_KEY_HASH (name);
216
- auto rawValue = RawValue{pair.second };
217
- visit (nameHash, name.c_str (), rawValue);
218
- }
219
- break ;
220
- }
221
- }
222
- }
223
-
224
171
} // namespace facebook::react
0 commit comments