Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,17 @@

namespace facebook::react {

namespace {

// Same as `a == b`. Props constructors pass the same string literal for a key
// on every parse, so `a` usually points to the characters stored for that key
// when the parser was prepared; comparing the pointers first skips `memcmp`.
inline bool keysEqual(std::string_view a, std::string_view b) noexcept {
return a.data() == b.data() ? a.size() == b.size() : a == b;
}

} // namespace

// During parser initialization, Props structs are used to parse
// "fake"/empty objects, and `at` is called repeatedly which tells us
// which props are accessed during parsing, and in which order.
Expand Down Expand Up @@ -81,7 +92,7 @@ const RawValue* RawPropsParser::at(
#endif
rawProps.keyIndexCursor_ = 0;
}
} while (key != keys_[rawProps.keyIndexCursor_]);
} while (!keysEqual(key, keys_[rawProps.keyIndexCursor_]));

auto valueIndex = rawProps.keyIndexToValueIndex_[rawProps.keyIndexCursor_];
return valueIndex == kRawPropsValueIndexEmpty ? nullptr
Expand Down
Loading