From 3c8ebe4ad02e5362a8c5849194ebbbddac11ea5c Mon Sep 17 00:00:00 2001 From: Ruslan Shestopalyuk Date: Tue, 28 Mar 2023 08:52:08 -0700 Subject: [PATCH] Fix hashing function in event name mapping in PerformanceEntryReporter (#36682) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/36682 ## Changelog: [Internal][Fix] - Fix hashing function in event name mapping in PerformanceEntryReporter A textbook mistake, when mapping event names via the constant lookup table, only the first 8 characters were effectively taken into account, thus mixing names of some events. Reviewed By: rubennorte Differential Revision: D44462195 fbshipit-source-id: d8845e74aa77b20d0fc66d3689836ca17a7213d5 --- .../Libraries/WebPerformance/PerformanceEntryReporter.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/react-native/Libraries/WebPerformance/PerformanceEntryReporter.cpp b/packages/react-native/Libraries/WebPerformance/PerformanceEntryReporter.cpp index 959b1c454f01..02661350f095 100644 --- a/packages/react-native/Libraries/WebPerformance/PerformanceEntryReporter.cpp +++ b/packages/react-native/Libraries/WebPerformance/PerformanceEntryReporter.cpp @@ -273,10 +273,9 @@ void PerformanceEntryReporter::scheduleFlushBuffer() { struct StrKey { uint32_t key; - constexpr StrKey(const char *s) - : key(folly::hash::fnv32_buf(s, sizeof(s) - 1)) {} + StrKey(const char *s) : key(folly::hash::fnv32_buf(s, std::strlen(s))) {} - constexpr bool operator==(const StrKey &rhs) const { + bool operator==(const StrKey &rhs) const { return key == rhs.key; } };