mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Fix string key issue with constexpr StrKey in Performance C++ native module
Summary:
I encountered build error when using performance API in catalyst android mobile app. The error message P617433618 points at using non-const `std::strlen` API in a `constexpr`.
```
$ buck install catalyst-android
...
stderr: xplat/js/react-native-github/Libraries/WebPerformance/PerformanceEntryReporter.cpp:208:13: error: constexpr constructor never produces a constant expression [-Winvalid-constexpr]
constexpr StrKey(const char *s)
^
xplat/js/react-native-github/Libraries/WebPerformance/PerformanceEntryReporter.cpp:209:39: note: non-constexpr function 'strlen' cannot be used in a constant expression
: key(folly::hash::fnv32_buf(s, std::strlen(s))) {}
```
Changelog:
[General][Fixed] - Fixed string key calculation in constexpr from Performance C++ native module.
Reviewed By: javache
Differential Revision: D43136624
fbshipit-source-id: c691671b157b507745c67a505c91f75cf6b878d1
This commit is contained in:
committed by
Facebook GitHub Bot
parent
d6e9891577
commit
6faddc3870
@@ -206,7 +206,7 @@ void PerformanceEntryReporter::scheduleFlushBuffer() {
|
||||
struct StrKey {
|
||||
uint32_t key;
|
||||
constexpr StrKey(const char *s)
|
||||
: key(folly::hash::fnv32_buf(s, std::strlen(s))) {}
|
||||
: key(folly::hash::fnv32_buf(s, sizeof(s) - 1)) {}
|
||||
|
||||
constexpr bool operator==(const StrKey &rhs) const {
|
||||
return key == rhs.key;
|
||||
|
||||
Reference in New Issue
Block a user