mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/49786 Most of these call-sites are only used for exceptional scenarios, so we can just rely on std::to_string and do string concatenation. For a few others that may be more perf-sensitive, I switched over to `snprintf`. Changelog: [Internal] Reviewed By: sammy-SC Differential Revision: D70402439 fbshipit-source-id: 3b90ebb13a7bf1c6cf30722ef636e5e8498a5b26
45 lines
1.0 KiB
C++
45 lines
1.0 KiB
C++
/*
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
|
|
#include "JSExecutor.h"
|
|
|
|
#include "RAMBundleRegistry.h"
|
|
|
|
#include <jsinspector-modern/ReactCdp.h>
|
|
#include <react/timing/primitives.h>
|
|
|
|
#include <array>
|
|
#include <chrono>
|
|
|
|
namespace facebook::react {
|
|
|
|
std::string JSExecutor::getSyntheticBundlePath(
|
|
uint32_t bundleId,
|
|
const std::string& bundlePath) {
|
|
if (bundleId == RAMBundleRegistry::MAIN_BUNDLE_ID) {
|
|
return bundlePath;
|
|
}
|
|
|
|
std::array<char, 32> buffer{};
|
|
std::snprintf(buffer.data(), buffer.size(), "seg-%u.js", bundleId);
|
|
return buffer.data();
|
|
}
|
|
|
|
double JSExecutor::performanceNow() {
|
|
return chronoToDOMHighResTimeStamp(std::chrono::steady_clock::now());
|
|
}
|
|
|
|
jsinspector_modern::RuntimeTargetDelegate&
|
|
JSExecutor::getRuntimeTargetDelegate() {
|
|
if (!runtimeTargetDelegate_) {
|
|
runtimeTargetDelegate_.emplace(getDescription());
|
|
}
|
|
return *runtimeTargetDelegate_;
|
|
}
|
|
|
|
} // namespace facebook::react
|