diff --git a/packages/react-native/ReactCommon/jsinspector-modern/cdp/CdpJson.cpp b/packages/react-native/ReactCommon/jsinspector-modern/cdp/CdpJson.cpp index b5efccb43f7..5b50cebfb89 100644 --- a/packages/react-native/ReactCommon/jsinspector-modern/cdp/CdpJson.cpp +++ b/packages/react-native/ReactCommon/jsinspector-modern/cdp/CdpJson.cpp @@ -49,7 +49,7 @@ std::string jsonResult(RequestId id, const folly::dynamic& result) { } std::string jsonNotification( - std::string_view method, + const std::string& method, std::optional params) { auto dynamicNotification = folly::dynamic::object("method", method); if (params) { @@ -60,7 +60,7 @@ std::string jsonNotification( std::string jsonRequest( RequestId id, - std::string_view method, + const std::string& method, std::optional params) { auto dynamicRequest = folly::dynamic::object("id", id)("method", method); if (params) { diff --git a/packages/react-native/ReactCommon/jsinspector-modern/cdp/CdpJson.h b/packages/react-native/ReactCommon/jsinspector-modern/cdp/CdpJson.h index 348ade26874..12e536366e0 100644 --- a/packages/react-native/ReactCommon/jsinspector-modern/cdp/CdpJson.h +++ b/packages/react-native/ReactCommon/jsinspector-modern/cdp/CdpJson.h @@ -118,7 +118,7 @@ std::string jsonResult( * \param params Optional payload object. */ std::string jsonNotification( - std::string_view method, + const std::string& method, std::optional params = std::nullopt); /** @@ -132,7 +132,7 @@ std::string jsonNotification( */ std::string jsonRequest( RequestId id, - std::string_view method, + const std::string& method, std::optional params = std::nullopt); } // namespace facebook::react::jsinspector_modern::cdp diff --git a/packages/react-native/ReactCommon/jsinspector-modern/tracing/PerformanceTracer.cpp b/packages/react-native/ReactCommon/jsinspector-modern/tracing/PerformanceTracer.cpp index 2aed5b2e751..959525080a0 100644 --- a/packages/react-native/ReactCommon/jsinspector-modern/tracing/PerformanceTracer.cpp +++ b/packages/react-native/ReactCommon/jsinspector-modern/tracing/PerformanceTracer.cpp @@ -124,7 +124,7 @@ std::optional> PerformanceTracer::stopTracing() { } void PerformanceTracer::reportMark( - const std::string_view& name, + const std::string& name, HighResTimeStamp start, folly::dynamic&& detail) { if (!tracingAtomic_) { @@ -137,7 +137,7 @@ void PerformanceTracer::reportMark( } enqueueEvent(PerformanceTracerEventMark{ - .name = std::string(name), + .name = name, .start = start, .detail = std::move(detail), .threadId = getCurrentThreadId(), @@ -145,7 +145,7 @@ void PerformanceTracer::reportMark( } void PerformanceTracer::reportMeasure( - const std::string_view& name, + const std::string& name, HighResTimeStamp start, HighResDuration duration, folly::dynamic&& detail) { @@ -159,7 +159,7 @@ void PerformanceTracer::reportMeasure( } enqueueEvent(PerformanceTracerEventMeasure{ - .name = std::string(name), + .name = name, .start = start, .duration = duration, .detail = std::move(detail), @@ -168,7 +168,7 @@ void PerformanceTracer::reportMeasure( } void PerformanceTracer::reportTimeStamp( - std::string name, + const std::string& name, std::optional start, std::optional end, std::optional trackName, @@ -184,7 +184,7 @@ void PerformanceTracer::reportTimeStamp( } enqueueEvent(PerformanceTracerEventTimeStamp{ - .name = std::move(name), + .name = name, .start = std::move(start), .end = std::move(end), .trackName = std::move(trackName), diff --git a/packages/react-native/ReactCommon/jsinspector-modern/tracing/PerformanceTracer.h b/packages/react-native/ReactCommon/jsinspector-modern/tracing/PerformanceTracer.h index 60faff48a0b..de63396712e 100644 --- a/packages/react-native/ReactCommon/jsinspector-modern/tracing/PerformanceTracer.h +++ b/packages/react-native/ReactCommon/jsinspector-modern/tracing/PerformanceTracer.h @@ -65,7 +65,7 @@ class PerformanceTracer { * See https://w3c.github.io/user-timing/#mark-method. */ void reportMark( - const std::string_view& name, + const std::string& name, HighResTimeStamp start, folly::dynamic&& detail = nullptr); @@ -76,7 +76,7 @@ class PerformanceTracer { * See https://w3c.github.io/user-timing/#measure-method. */ void reportMeasure( - const std::string_view& name, + const std::string& name, HighResTimeStamp start, HighResDuration duration, folly::dynamic&& detail = nullptr); @@ -89,7 +89,7 @@ class PerformanceTracer { https://developer.chrome.com/docs/devtools/performance/extension#inject_your_data_with_consoletimestamp */ void reportTimeStamp( - std::string name, + const std::string& name, std::optional start = std::nullopt, std::optional end = std::nullopt, std::optional trackName = std::nullopt, diff --git a/packages/react-native/ReactCommon/jsinspector-modern/tracing/RuntimeSamplingProfile.h b/packages/react-native/ReactCommon/jsinspector-modern/tracing/RuntimeSamplingProfile.h index a6c593cba2d..3016aa3eda5 100644 --- a/packages/react-native/ReactCommon/jsinspector-modern/tracing/RuntimeSamplingProfile.h +++ b/packages/react-native/ReactCommon/jsinspector-modern/tracing/RuntimeSamplingProfile.h @@ -49,8 +49,14 @@ struct RuntimeSamplingProfile { /// id of the corresponding script in the VM. uint32_t scriptId; /// name of the function that represents call frame. + /// Storing a std::string_view should be considered safe here, beacause + /// the lifetime of the string contents are guaranteed as long as the raw + // Sampling Profiler object from Hermes is allocated. std::string_view functionName; /// source url of the corresponding script in the VM. + /// Storing a std::string_view should be considered safe here, beacause + /// the lifetime of the string contents are guaranteed as long as the raw + // Sampling Profiler object from Hermes is allocated. std::optional scriptURL = std::nullopt; /// 0-based line number of the corresponding call frame. std::optional lineNumber = std::nullopt;