mirror of
https://github.com/facebook/react-native.git
synced 2026-11-18 20:19:07 +00:00
Apply clang-tidy setting: react/renderer|perflogger (#52739)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/52739 Changelog: [Internal] Reviewed By: rshest Differential Revision: D78634924 fbshipit-source-id: c0ad2c6162e1d5929b2b097b884f5989d040d576
This commit is contained in:
1 parent
14986a8dbf
commit
730a0d5aef
26 files changed
+84
-82
No files matched your search
+1
-1
@@ -29,7 +29,7 @@ ComponentDescriptorRegistry::ComponentDescriptorRegistry(
|
||||
contextContainer_(std::move(contextContainer)) {}
|
||||
|
||||
void ComponentDescriptorRegistry::add(
|
||||
ComponentDescriptorProvider componentDescriptorProvider) const {
|
||||
const ComponentDescriptorProvider& componentDescriptorProvider) const {
|
||||
std::unique_lock lock(mutex_);
|
||||
|
||||
auto componentDescriptor = componentDescriptorProvider.constructor(
|
||||
|
||||
+2
-1
@@ -71,7 +71,8 @@ class ComponentDescriptorRegistry {
|
||||
* To be used by `ComponentDescriptorProviderRegistry` only.
|
||||
* Thread safe.
|
||||
*/
|
||||
void add(ComponentDescriptorProvider componentDescriptorProvider) const;
|
||||
void add(
|
||||
const ComponentDescriptorProvider& componentDescriptorProvider) const;
|
||||
|
||||
mutable std::shared_mutex mutex_;
|
||||
mutable std::unordered_map<ComponentHandle, SharedComponentDescriptor>
|
||||
|
||||
@@ -44,8 +44,7 @@ RawProps::RawProps(folly::dynamic dynamic) noexcept {
|
||||
dynamic_ = std::move(dynamic);
|
||||
}
|
||||
|
||||
RawProps::RawProps(const RawProps& other) noexcept {
|
||||
mode_ = other.mode_;
|
||||
RawProps::RawProps(const RawProps& other) noexcept : mode_(other.mode_) {
|
||||
if (mode_ == Mode::JSI) {
|
||||
runtime_ = other.runtime_;
|
||||
value_ = jsi::Value(*runtime_, other.value_);
|
||||
|
||||
@@ -50,7 +50,7 @@ class RawProps final {
|
||||
*/
|
||||
RawProps(jsi::Runtime& runtime, const jsi::Value& value) noexcept;
|
||||
|
||||
explicit RawProps(const RawProps& rawProps) noexcept;
|
||||
explicit RawProps(const RawProps& other) noexcept;
|
||||
RawProps(RawProps&& other) noexcept = default;
|
||||
|
||||
RawProps& operator=(const RawProps& other) noexcept = delete;
|
||||
|
||||
@@ -164,7 +164,7 @@ void RawPropsParser::preparse(const RawProps& rawProps) const noexcept {
|
||||
}
|
||||
|
||||
rawProps.keyIndexToValueIndex_[keyIndex] = valueIndex;
|
||||
rawProps.values_.push_back(RawValue{pair.second});
|
||||
rawProps.values_.emplace_back(pair.second);
|
||||
valueIndex++;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -492,7 +492,7 @@ TEST(CSSSyntaxParser, solidus_or_whitespace) {
|
||||
|
||||
auto delimValue1 = parser.consumeComponentValue<bool>(
|
||||
CSSDelimiter::SolidusOrWhitespace,
|
||||
[](const CSSPreservedToken& token) { return true; });
|
||||
[](const CSSPreservedToken& /*token*/) { return true; });
|
||||
|
||||
EXPECT_FALSE(delimValue1);
|
||||
}
|
||||
@@ -549,8 +549,8 @@ TEST(CSSSyntaxParser, component_value_not_consumed_on_visitor_failure) {
|
||||
EXPECT_TRUE(visitor2Attempted);
|
||||
|
||||
bool visitor3Attempted = false;
|
||||
bool visitor3Ret =
|
||||
parser.consumeComponentValue<bool>([&](const CSSPreservedToken& token) {
|
||||
bool visitor3Ret = parser.consumeComponentValue<bool>(
|
||||
[&](const CSSPreservedToken& /*token*/) {
|
||||
visitor3Attempted = true;
|
||||
return true;
|
||||
});
|
||||
|
||||
@@ -88,6 +88,7 @@ std::vector<StubView> getDebugChildren(
|
||||
const StubView& stubView,
|
||||
DebugStringConvertibleOptions /*options*/) {
|
||||
std::vector<StubView> result;
|
||||
result.reserve(stubView.children.size());
|
||||
for (const auto& child : stubView.children) {
|
||||
result.push_back(*child);
|
||||
}
|
||||
|
||||
@@ -26,10 +26,11 @@ std::string getComponentName(const ShadowView& shadowView) {
|
||||
}
|
||||
} // namespace
|
||||
|
||||
StubViewTree::StubViewTree(const ShadowView& shadowView) {
|
||||
StubViewTree::StubViewTree(const ShadowView& shadowView)
|
||||
: rootTag_(shadowView.tag) {
|
||||
auto view = std::make_shared<StubView>();
|
||||
view->update(shadowView);
|
||||
rootTag_ = shadowView.tag;
|
||||
|
||||
registry_[shadowView.tag] = view;
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -32,11 +32,11 @@ class DummyShadowTreeDelegate : public ShadowTreeDelegate {
|
||||
const RootShadowNode::Unshared& newRootShadowNode,
|
||||
const ShadowTree::CommitOptions& /*commitOptions*/) const override {
|
||||
return newRootShadowNode;
|
||||
};
|
||||
}
|
||||
|
||||
void shadowTreeDidFinishTransaction(
|
||||
std::shared_ptr<const MountingCoordinator> mountingCoordinator,
|
||||
bool mountSynchronously) const override {};
|
||||
bool /*mountSynchronously*/) const override {}
|
||||
};
|
||||
|
||||
namespace {
|
||||
@@ -47,7 +47,7 @@ const ShadowNode* findDescendantNode(
|
||||
return &shadowNode;
|
||||
}
|
||||
|
||||
for (auto childNode : shadowNode.getChildren()) {
|
||||
for (const auto& childNode : shadowNode.getChildren()) {
|
||||
auto descendant = findDescendantNode(*childNode, family);
|
||||
if (descendant != nullptr) {
|
||||
return descendant;
|
||||
|
||||
+1
-1
@@ -44,7 +44,7 @@ void IntersectionObserverManager::observe(
|
||||
const ShadowNodeFamily::Shared& shadowNodeFamily,
|
||||
std::vector<Float> thresholds,
|
||||
std::optional<std::vector<Float>> rootThresholds,
|
||||
const UIManager& uiManager) {
|
||||
const UIManager& /*uiManager*/) {
|
||||
TraceSection s("IntersectionObserverManager::observe");
|
||||
|
||||
auto surfaceId = shadowNodeFamily->getSurfaceId();
|
||||
|
||||
+3
-5
@@ -18,7 +18,7 @@ void MutationObserverManager::observe(
|
||||
MutationObserverId mutationObserverId,
|
||||
std::shared_ptr<const ShadowNode> shadowNode,
|
||||
bool observeSubtree,
|
||||
const UIManager& uiManager) {
|
||||
const UIManager& /*uiManager*/) {
|
||||
TraceSection s("MutationObserverManager::observe");
|
||||
|
||||
auto surfaceId = shadowNode->getSurfaceId();
|
||||
@@ -55,7 +55,7 @@ void MutationObserverManager::unobserveAll(
|
||||
|
||||
void MutationObserverManager::connect(
|
||||
UIManager& uiManager,
|
||||
std::function<void(std::vector<MutationRecord>&)> onMutations) {
|
||||
OnMutations&& onMutations) {
|
||||
TraceSection s("MutationObserverManager::connect");
|
||||
|
||||
// Fail-safe in case the caller doesn't guarantee consistency.
|
||||
@@ -63,7 +63,7 @@ void MutationObserverManager::connect(
|
||||
return;
|
||||
}
|
||||
|
||||
onMutations_ = onMutations;
|
||||
onMutations_ = std::move(onMutations);
|
||||
|
||||
uiManager.registerCommitHook(*this);
|
||||
commitHookRegistered_ = true;
|
||||
@@ -123,8 +123,6 @@ void MutationObserverManager::runMutationObservations(
|
||||
if (!mutationRecords.empty()) {
|
||||
onMutations_(mutationRecords);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
} // namespace facebook::react
|
||||
+4
-4
@@ -16,6 +16,8 @@
|
||||
|
||||
namespace facebook::react {
|
||||
|
||||
using OnMutations = std::function<void(std::vector<MutationRecord>&)>;
|
||||
|
||||
class MutationObserverManager final : public UIManagerCommitHook {
|
||||
public:
|
||||
MutationObserverManager();
|
||||
@@ -28,9 +30,7 @@ class MutationObserverManager final : public UIManagerCommitHook {
|
||||
|
||||
void unobserveAll(MutationObserverId mutationObserverId);
|
||||
|
||||
void connect(
|
||||
UIManager& uiManager,
|
||||
std::function<void(std::vector<MutationRecord>&)> onMutations);
|
||||
void connect(UIManager& uiManager, OnMutations&& onMutations);
|
||||
|
||||
void disconnect(UIManager& uiManager);
|
||||
|
||||
@@ -51,7 +51,7 @@ class MutationObserverManager final : public UIManagerCommitHook {
|
||||
std::unordered_map<MutationObserverId, MutationObserver>>
|
||||
observersBySurfaceId_;
|
||||
|
||||
std::function<void(std::vector<MutationRecord>&)> onMutations_;
|
||||
OnMutations onMutations_;
|
||||
bool commitHookRegistered_{};
|
||||
|
||||
void runMutationObservations(
|
||||
|
||||
+3
-3
@@ -187,7 +187,7 @@ TEST_P(
|
||||
3,
|
||||
[&](jsi::Runtime& /*unused*/,
|
||||
const jsi::Value& /*unused*/,
|
||||
const jsi::Value* arguments,
|
||||
const jsi::Value* /*arguments*/,
|
||||
size_t /*unused*/) -> jsi::Value {
|
||||
microtaskPosition = nextOperationPosition;
|
||||
nextOperationPosition++;
|
||||
@@ -906,7 +906,7 @@ TEST_P(RuntimeSchedulerTest, sameThreadTaskCreatesImmediatePriorityTask) {
|
||||
std::thread t1([this, &didRunSynchronousTask, &didRunSubsequentTask]() {
|
||||
runtimeScheduler_->executeNowOnTheSameThread(
|
||||
[this, &didRunSynchronousTask, &didRunSubsequentTask](
|
||||
jsi::Runtime& runtime) {
|
||||
jsi::Runtime& /*runtime*/) {
|
||||
didRunSynchronousTask = true;
|
||||
|
||||
auto callback = createHostFunctionFromLambda(
|
||||
@@ -994,7 +994,7 @@ TEST_P(RuntimeSchedulerTest, sameThreadTaskCreatesLowPriorityTask) {
|
||||
std::thread t1([this, &didRunSynchronousTask, &didRunSubsequentTask]() {
|
||||
runtimeScheduler_->executeNowOnTheSameThread(
|
||||
[this, &didRunSynchronousTask, &didRunSubsequentTask](
|
||||
jsi::Runtime& runtime) {
|
||||
jsi::Runtime& /*runtime*/) {
|
||||
didRunSynchronousTask = true;
|
||||
|
||||
auto callback = createHostFunctionFromLambda(
|
||||
|
||||
@@ -27,10 +27,9 @@ namespace facebook::react {
|
||||
Scheduler::Scheduler(
|
||||
const SchedulerToolbox& schedulerToolbox,
|
||||
UIManagerAnimationDelegate* animationDelegate,
|
||||
SchedulerDelegate* delegate) {
|
||||
runtimeExecutor_ = schedulerToolbox.runtimeExecutor;
|
||||
contextContainer_ = schedulerToolbox.contextContainer;
|
||||
|
||||
SchedulerDelegate* delegate)
|
||||
: runtimeExecutor_(schedulerToolbox.runtimeExecutor),
|
||||
contextContainer_(schedulerToolbox.contextContainer) {
|
||||
// Creating a container for future `EventDispatcher` instance.
|
||||
eventDispatcher_ = std::make_shared<std::optional<const EventDispatcher>>();
|
||||
|
||||
|
||||
+2
-2
@@ -156,7 +156,7 @@ TextMeasurement doMeasure(
|
||||
|
||||
TextLayoutManager::TextLayoutManager(
|
||||
const std::shared_ptr<const ContextContainer>& contextContainer)
|
||||
: contextContainer_(contextContainer),
|
||||
: contextContainer_(std::move(contextContainer)),
|
||||
textMeasureCache_(kSimpleThreadSafeCacheSizeCap),
|
||||
lineMeasureCache_(kSimpleThreadSafeCacheSizeCap),
|
||||
preparedTextCache_(static_cast<size_t>(
|
||||
@@ -236,7 +236,7 @@ TextMeasurement TextLayoutManager::measureCachedSpannableById(
|
||||
// TODO: currently we do not support attachments for cached IDs - should we?
|
||||
auto attachments = TextMeasurement::Attachments{};
|
||||
|
||||
return TextMeasurement{size, attachments};
|
||||
return TextMeasurement{.size = size, .attachments = attachments};
|
||||
}
|
||||
|
||||
LinesMeasurements TextLayoutManager::measureLines(
|
||||
|
||||
@@ -93,7 +93,7 @@ std::tuple<EventPath, EventPath> PointerHoverTracker::diffEventPath(
|
||||
for (auto nodeIt = myIt; nodeIt != myEventPath.rend(); nodeIt++) {
|
||||
const auto& latestNode = getLatestNode(*nodeIt, uiManager);
|
||||
if (latestNode != nullptr) {
|
||||
removed.push_back(*latestNode);
|
||||
removed.emplace_back(*latestNode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ std::tuple<EventPath, EventPath> PointerHoverTracker::diffEventPath(
|
||||
for (auto nodeIt = otherIt; nodeIt != otherEventPath.rend(); nodeIt++) {
|
||||
const auto& latestNode = other.getLatestNode(*nodeIt, uiManager);
|
||||
if (latestNode != nullptr) {
|
||||
added.push_back(*latestNode);
|
||||
added.emplace_back(*latestNode);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -516,7 +516,7 @@ std::shared_ptr<const ShadowNode> UIManager::findShadowNodeByTag_DEPRECATED(
|
||||
auto shadowNode = std::shared_ptr<const ShadowNode>{};
|
||||
|
||||
shadowTreeRegistry_.enumerate([&](const ShadowTree& shadowTree, bool& stop) {
|
||||
const RootShadowNode* rootShadowNode;
|
||||
const RootShadowNode* rootShadowNode = nullptr;
|
||||
// The public interface of `ShadowTree` discourages accessing a stored
|
||||
// pointer to a root node because of the possible data race.
|
||||
// To work around this, we ask for a commit and immediately cancel it
|
||||
|
||||
+2
-2
@@ -22,11 +22,11 @@ class FakeShadowTreeDelegate : public ShadowTreeDelegate {
|
||||
const RootShadowNode::Unshared& newRootShadowNode,
|
||||
const ShadowTree::CommitOptions& /*commitOptions*/) const override {
|
||||
return newRootShadowNode;
|
||||
};
|
||||
}
|
||||
|
||||
void shadowTreeDidFinishTransaction(
|
||||
std::shared_ptr<const MountingCoordinator> mountingCoordinator,
|
||||
bool mountSynchronously) const override {};
|
||||
bool /*mountSynchronously*/) const override {}
|
||||
};
|
||||
|
||||
class LazyShadowTreeRevisionConsistencyManagerTest : public ::testing::Test {
|
||||
|
||||
+5
-7
@@ -36,8 +36,6 @@ static inline void listenToAllPointerEvents(ViewProps& props) {
|
||||
class PointerEventsProcessorTest : public ::testing::Test {
|
||||
public:
|
||||
PointerEventsProcessorTest() {
|
||||
surfaceId_ = 0;
|
||||
|
||||
auto contextContainer = std::make_shared<ContextContainer>();
|
||||
|
||||
ComponentDescriptorProviderRegistry componentDescriptorProviderRegistry{};
|
||||
@@ -180,7 +178,7 @@ class PointerEventsProcessorTest : public ::testing::Test {
|
||||
*uiManager_,
|
||||
*contextContainer);
|
||||
shadowTree->commit(
|
||||
[this](const RootShadowNode& oldRootShadowNode) {
|
||||
[this](const RootShadowNode& /*oldRootShadowNode*/) {
|
||||
return std::static_pointer_cast<RootShadowNode>(this->rootNode_);
|
||||
},
|
||||
{true});
|
||||
@@ -199,13 +197,13 @@ class PointerEventsProcessorTest : public ::testing::Test {
|
||||
|
||||
EventLog dispatchPointerEvent(
|
||||
const std::shared_ptr<const ShadowNode>& target,
|
||||
std::string eventName,
|
||||
PointerEvent eventPayload) {
|
||||
const std::string& eventName,
|
||||
const PointerEvent& eventPayload) {
|
||||
EventLog eventLog;
|
||||
auto dispatchCallback = [&eventLog](
|
||||
const ShadowNode& targetNode,
|
||||
const std::string& type,
|
||||
ReactEventPriority priority,
|
||||
ReactEventPriority /*priority*/,
|
||||
const EventPayload& eventPayload) {
|
||||
eventLog.push_back({
|
||||
.tag = targetNode.getTag(),
|
||||
@@ -223,7 +221,7 @@ class PointerEventsProcessorTest : public ::testing::Test {
|
||||
return eventLog;
|
||||
}
|
||||
|
||||
SurfaceId surfaceId_;
|
||||
SurfaceId surfaceId_{0};
|
||||
|
||||
std::shared_ptr<RootShadowNode> rootNode_;
|
||||
std::shared_ptr<ViewShadowNode> nodeA_;
|
||||
|
||||
+2
-2
@@ -14,13 +14,13 @@ BridgelessNativeMethodCallInvoker::BridgelessNativeMethodCallInvoker(
|
||||
: messageQueueThread_(std::move(messageQueueThread)) {}
|
||||
|
||||
void BridgelessNativeMethodCallInvoker::invokeAsync(
|
||||
const std::string& methodName,
|
||||
const std::string& /*methodName*/,
|
||||
NativeMethodCallFunc&& func) noexcept {
|
||||
messageQueueThread_->runOnQueue(std::move(func));
|
||||
}
|
||||
|
||||
void BridgelessNativeMethodCallInvoker::invokeSync(
|
||||
const std::string& methodName,
|
||||
const std::string& /*methodName*/,
|
||||
NativeMethodCallFunc&& func) {
|
||||
messageQueueThread_->runOnQueueSync(std::move(func));
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ void BufferedRuntimeExecutor::flush() {
|
||||
}
|
||||
|
||||
void BufferedRuntimeExecutor::unsafeFlush() {
|
||||
while (queue_.size() > 0) {
|
||||
while (!queue_.empty()) {
|
||||
const BufferedWork& bufferedWork = queue_.top();
|
||||
Work work = bufferedWork.work_;
|
||||
runtimeExecutor_(std::move(work));
|
||||
|
||||
@@ -36,7 +36,9 @@ std::shared_ptr<RuntimeScheduler> createRuntimeScheduler(
|
||||
RuntimeSchedulerTaskErrorHandler taskErrorHandler) {
|
||||
std::shared_ptr<RuntimeScheduler> scheduler =
|
||||
std::make_shared<RuntimeScheduler>(
|
||||
runtimeExecutor, HighResTimeStamp::now, taskErrorHandler);
|
||||
std::move(runtimeExecutor),
|
||||
HighResTimeStamp::now,
|
||||
std::move(taskErrorHandler));
|
||||
scheduler->setPerformanceEntryReporter(
|
||||
// FIXME: Move creation of PerformanceEntryReporter to here and
|
||||
// guarantee that its lifetime is the same as the runtime.
|
||||
@@ -54,7 +56,7 @@ ReactInstance::ReactInstance(
|
||||
JsErrorHandler::OnJsError onJsError,
|
||||
jsinspector_modern::HostTarget* parentInspectorTarget)
|
||||
: runtime_(std::move(runtime)),
|
||||
jsMessageQueueThread_(jsMessageQueueThread),
|
||||
jsMessageQueueThread_(std::move(jsMessageQueueThread)),
|
||||
timerManager_(std::move(timerManager)),
|
||||
jsErrorHandler_(std::make_shared<JsErrorHandler>(std::move(onJsError))),
|
||||
parentInspectorTarget_(parentInspectorTarget) {
|
||||
@@ -93,7 +95,7 @@ ReactInstance::ReactInstance(
|
||||
}
|
||||
};
|
||||
|
||||
if (parentInspectorTarget_) {
|
||||
if (parentInspectorTarget_ != nullptr) {
|
||||
auto executor = parentInspectorTarget_->executorFromThis();
|
||||
|
||||
auto bufferedRuntimeExecutorThatWaitsForInspectorSetup =
|
||||
@@ -155,7 +157,7 @@ ReactInstance::ReactInstance(
|
||||
}
|
||||
|
||||
void ReactInstance::unregisterFromInspector() {
|
||||
if (inspectorTarget_) {
|
||||
if (inspectorTarget_ != nullptr) {
|
||||
assert(runtimeInspectorTarget_);
|
||||
inspectorTarget_->unregisterRuntime(*runtimeInspectorTarget_);
|
||||
|
||||
@@ -234,7 +236,7 @@ void ReactInstance::loadScript(
|
||||
beforeLoad(runtime);
|
||||
}
|
||||
TraceSection s("ReactInstance::loadScript");
|
||||
bool hasLogger(ReactMarker::logTaggedMarkerBridgelessImpl);
|
||||
bool hasLogger(ReactMarker::logTaggedMarkerBridgelessImpl != nullptr);
|
||||
if (hasLogger) {
|
||||
ReactMarker::logTaggedMarkerBridgeless(
|
||||
ReactMarker::RUN_JS_BUNDLE_START, scriptName.c_str());
|
||||
@@ -344,7 +346,7 @@ void ReactInstance::registerSegment(
|
||||
}
|
||||
auto buffer = std::make_shared<BigStringBuffer>(std::move(script));
|
||||
|
||||
bool hasLogger(ReactMarker::logTaggedMarkerBridgelessImpl);
|
||||
bool hasLogger(ReactMarker::logTaggedMarkerBridgelessImpl != nullptr);
|
||||
if (hasLogger) {
|
||||
ReactMarker::logTaggedMarkerBridgeless(
|
||||
ReactMarker::REGISTER_JS_SEGMENT_START, tag.c_str());
|
||||
@@ -365,7 +367,7 @@ void ReactInstance::registerSegment(
|
||||
namespace {
|
||||
void defineReactInstanceFlags(
|
||||
jsi::Runtime& runtime,
|
||||
ReactInstance::JSRuntimeFlags options) noexcept {
|
||||
const ReactInstance::JSRuntimeFlags& options) noexcept {
|
||||
defineReadOnlyGlobal(runtime, "RN$Bridgeless", jsi::Value(true));
|
||||
|
||||
if (options.isProfiling) {
|
||||
@@ -390,7 +392,10 @@ bool isTruthy(jsi::Runtime& runtime, const jsi::Value& value) {
|
||||
void ReactInstance::initializeRuntime(
|
||||
JSRuntimeFlags options,
|
||||
BindingsInstallFunc bindingsInstallFunc) noexcept {
|
||||
runtimeScheduler_->scheduleWork([this, options, bindingsInstallFunc](
|
||||
runtimeScheduler_->scheduleWork([this,
|
||||
options = std::move(options),
|
||||
bindingsInstallFunc =
|
||||
std::move(bindingsInstallFunc)](
|
||||
jsi::Runtime& runtime) {
|
||||
TraceSection s("ReactInstance::initializeRuntime");
|
||||
|
||||
@@ -606,7 +611,7 @@ void ReactInstance::handleMemoryPressureJs(int pressureLevel) {
|
||||
TRIM_MEMORY_RUNNING_MODERATE = 5,
|
||||
TRIM_MEMORY_UI_HIDDEN = 20,
|
||||
};
|
||||
const char* levelName;
|
||||
const char* levelName = nullptr;
|
||||
switch (pressureLevel) {
|
||||
case TRIM_MEMORY_BACKGROUND:
|
||||
levelName = "TRIM_MEMORY_BACKGROUND";
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
#include <react/runtime/BufferedRuntimeExecutor.h>
|
||||
#include <react/runtime/JSRuntimeFactory.h>
|
||||
#include <react/runtime/TimerManager.h>
|
||||
#include <vector>
|
||||
|
||||
namespace facebook::react {
|
||||
|
||||
@@ -41,7 +40,7 @@ class ReactInstance final : private jsinspector_modern::InstanceTargetDelegate {
|
||||
|
||||
struct JSRuntimeFlags {
|
||||
bool isProfiling = false;
|
||||
const std::string runtimeDiagnosticFlags = "";
|
||||
const std::string runtimeDiagnosticFlags;
|
||||
};
|
||||
|
||||
void initializeRuntime(
|
||||
|
||||
@@ -59,7 +59,7 @@ TimerManager::TimerManager(
|
||||
|
||||
void TimerManager::setRuntimeExecutor(
|
||||
RuntimeExecutor runtimeExecutor) noexcept {
|
||||
runtimeExecutor_ = runtimeExecutor;
|
||||
runtimeExecutor_ = std::move(runtimeExecutor);
|
||||
}
|
||||
|
||||
TimerHandle TimerManager::createReactNativeMicrotask(
|
||||
@@ -232,7 +232,7 @@ void TimerManager::attachGlobals(jsi::Runtime& runtime) {
|
||||
3, // Function, delay, ...args
|
||||
[this](
|
||||
jsi::Runtime& rt,
|
||||
const jsi::Value& thisVal,
|
||||
const jsi::Value& /*thisVal*/,
|
||||
const jsi::Value* args,
|
||||
size_t count) {
|
||||
if (count == 0) {
|
||||
@@ -272,7 +272,7 @@ void TimerManager::attachGlobals(jsi::Runtime& runtime) {
|
||||
1, // timerID
|
||||
[this](
|
||||
jsi::Runtime& rt,
|
||||
const jsi::Value& thisVal,
|
||||
const jsi::Value& /*thisVal*/,
|
||||
const jsi::Value* args,
|
||||
size_t count) {
|
||||
if (count > 0 && args[0].isNumber()) {
|
||||
@@ -291,7 +291,7 @@ void TimerManager::attachGlobals(jsi::Runtime& runtime) {
|
||||
3, // Function, delay, ...args
|
||||
[this](
|
||||
jsi::Runtime& rt,
|
||||
const jsi::Value& thisVal,
|
||||
const jsi::Value& /*thisVal*/,
|
||||
const jsi::Value* args,
|
||||
size_t count) {
|
||||
if (count == 0) {
|
||||
@@ -332,7 +332,7 @@ void TimerManager::attachGlobals(jsi::Runtime& runtime) {
|
||||
1, // timerID
|
||||
[this](
|
||||
jsi::Runtime& rt,
|
||||
const jsi::Value& thisVal,
|
||||
const jsi::Value& /*thisVal*/,
|
||||
const jsi::Value* args,
|
||||
size_t count) {
|
||||
if (count > 0 && args[0].isNumber()) {
|
||||
@@ -351,7 +351,7 @@ void TimerManager::attachGlobals(jsi::Runtime& runtime) {
|
||||
1, // callback
|
||||
[this](
|
||||
jsi::Runtime& rt,
|
||||
const jsi::Value& thisVal,
|
||||
const jsi::Value& /*thisVal*/,
|
||||
const jsi::Value* args,
|
||||
size_t count) {
|
||||
if (count == 0) {
|
||||
@@ -373,9 +373,9 @@ void TimerManager::attachGlobals(jsi::Runtime& runtime) {
|
||||
[callbackContainer = std::make_shared<jsi::Function>(
|
||||
args[0].getObject(rt).getFunction(rt))](
|
||||
jsi::Runtime& rt,
|
||||
const jsi::Value& thisVal,
|
||||
const jsi::Value* args,
|
||||
size_t count) {
|
||||
const jsi::Value& /*thisVal*/,
|
||||
const jsi::Value* /*args*/,
|
||||
size_t /*count*/) {
|
||||
auto performance =
|
||||
rt.global().getPropertyAsObject(rt, "performance");
|
||||
auto nowFn = performance.getPropertyAsFunction(rt, "now");
|
||||
@@ -402,7 +402,7 @@ void TimerManager::attachGlobals(jsi::Runtime& runtime) {
|
||||
1, // timerID
|
||||
[this](
|
||||
jsi::Runtime& rt,
|
||||
const jsi::Value& thisVal,
|
||||
const jsi::Value& /*thisVal*/,
|
||||
const jsi::Value* args,
|
||||
size_t count) {
|
||||
if (count > 0 && args[0].isNumber()) {
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
#include <memory>
|
||||
#include <queue>
|
||||
#include <utility>
|
||||
|
||||
#include <gmock/gmock.h>
|
||||
#include <gtest/gtest.h>
|
||||
@@ -32,15 +33,15 @@ class MockTimerRegistry : public PlatformTimerRegistry {
|
||||
|
||||
class MockMessageQueueThread : public MessageQueueThread {
|
||||
public:
|
||||
void runOnQueue(std::function<void()>&& func) {
|
||||
void runOnQueue(std::function<void()>&& func) override {
|
||||
callbackQueue_.push(func);
|
||||
}
|
||||
|
||||
// Unused
|
||||
void runOnQueueSync(std::function<void()>&&) {}
|
||||
void runOnQueueSync(std::function<void()>&& /*unused*/) override {}
|
||||
|
||||
// Unused
|
||||
void quitSynchronous() {}
|
||||
void quitSynchronous() override {}
|
||||
|
||||
void tick() {
|
||||
if (!callbackQueue_.empty()) {
|
||||
@@ -79,7 +80,7 @@ class ErrorUtils : public jsi::HostObject {
|
||||
1,
|
||||
[this](
|
||||
jsi::Runtime& runtime,
|
||||
const jsi::Value& thisValue,
|
||||
const jsi::Value& /*thisValue*/,
|
||||
const jsi::Value* arguments,
|
||||
size_t count) {
|
||||
if (count >= 1) {
|
||||
@@ -114,7 +115,7 @@ class ErrorUtils : public jsi::HostObject {
|
||||
|
||||
class ReactInstanceTest : public ::testing::Test {
|
||||
protected:
|
||||
ReactInstanceTest() {}
|
||||
ReactInstanceTest() = default;
|
||||
|
||||
void SetUp() override {
|
||||
auto runtime =
|
||||
@@ -152,7 +153,7 @@ class ReactInstanceTest : public ::testing::Test {
|
||||
step();
|
||||
|
||||
// Run the main bundle, so that native -> JS calls no longer get buffered.
|
||||
loadScript(script);
|
||||
loadScript(std::move(script));
|
||||
}
|
||||
|
||||
void initializeRuntimeWithScript(std::string script) {
|
||||
@@ -161,16 +162,16 @@ class ReactInstanceTest : public ::testing::Test {
|
||||
step();
|
||||
|
||||
// Run the main bundle, so that native -> JS calls no longer get buffered.
|
||||
loadScript(script);
|
||||
loadScript(std::move(script));
|
||||
}
|
||||
|
||||
jsi::Value tryEval(std::string js, std::string defaultVal) {
|
||||
jsi::Value tryEval(const std::string& js, const std::string& defaultVal) {
|
||||
return eval(
|
||||
"(function() { try { return " + js + "; } catch { return " +
|
||||
defaultVal + "; } })()");
|
||||
}
|
||||
|
||||
jsi::Value eval(std::string js) {
|
||||
jsi::Value eval(const std::string& js) {
|
||||
RuntimeExecutor runtimeExecutor = instance_->getUnbufferedRuntimeExecutor();
|
||||
jsi::Value ret = jsi::Value::undefined();
|
||||
runtimeExecutor([js, &ret](jsi::Runtime& runtime) {
|
||||
@@ -214,11 +215,11 @@ class ReactInstanceTest : public ::testing::Test {
|
||||
messageQueueThread_->guardedTick();
|
||||
}
|
||||
|
||||
jsi::Runtime* runtime_;
|
||||
jsi::Runtime* runtime_{};
|
||||
std::shared_ptr<MockMessageQueueThread> messageQueueThread_;
|
||||
std::unique_ptr<ReactInstance> instance_;
|
||||
std::shared_ptr<TimerManager> timerManager_;
|
||||
MockTimerRegistry* mockRegistry_;
|
||||
MockTimerRegistry* mockRegistry_{};
|
||||
std::shared_ptr<ErrorUtils> errorHandler_;
|
||||
};
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ bool FuseboxTracer::stopTracing(
|
||||
|
||||
for (auto& event : savedBuffer) {
|
||||
// For events with a custom track name, register track
|
||||
if (event.track.length() && !trackIdMap.contains(event.track)) {
|
||||
if (!event.track.empty() && !trackIdMap.contains(event.track)) {
|
||||
auto trackId = nextTrack++;
|
||||
trackIdMap[event.track] = trackId;
|
||||
traceEvents.push_back(folly::dynamic::object(
|
||||
@@ -94,7 +94,7 @@ bool FuseboxTracer::stopTracing(
|
||||
}
|
||||
}
|
||||
|
||||
if (traceEvents.size() >= 1) {
|
||||
if (!traceEvents.empty()) {
|
||||
resultCallback(traceEvents);
|
||||
}
|
||||
return true;
|
||||
|
||||
Reference in new issue
Block a user