diff --git a/src/inspector/v8-console.cc b/src/inspector/v8-console.cc index 752b50fa36..6701de3eb3 100644 --- a/src/inspector/v8-console.cc +++ b/src/inspector/v8-console.cc @@ -63,6 +63,7 @@ class ConsoleHelper { void reportCall(ConsoleAPIType type) { if (!m_info.Length()) return; std::vector> arguments; + arguments.reserve(m_info.Length()); for (int i = 0; i < m_info.Length(); ++i) arguments.push_back(m_info[i]); reportCall(type, arguments); } @@ -143,7 +144,7 @@ class ConsoleHelper { } void forEachSession(std::function callback) { - m_inspector->forEachSession(m_groupId, callback); + m_inspector->forEachSession(m_groupId, std::move(callback)); } private: diff --git a/src/inspector/v8-inspector-impl.cc b/src/inspector/v8-inspector-impl.cc index 62790a6335..7269700254 100644 --- a/src/inspector/v8-inspector-impl.cc +++ b/src/inspector/v8-inspector-impl.cc @@ -359,7 +359,8 @@ V8Console* V8InspectorImpl::console() { } void V8InspectorImpl::forEachContext( - int contextGroupId, std::function callback) { + int contextGroupId, + const std::function& callback) { auto it = m_contexts.find(contextGroupId); if (it == m_contexts.end()) return; std::vector ids; @@ -376,7 +377,8 @@ void V8InspectorImpl::forEachContext( } void V8InspectorImpl::forEachSession( - int contextGroupId, std::function callback) { + int contextGroupId, + const std::function& callback) { auto it = m_sessions.find(contextGroupId); if (it == m_sessions.end()) return; std::vector ids; @@ -411,7 +413,7 @@ V8InspectorImpl::EvaluateScope::~EvaluateScope() { class V8InspectorImpl::EvaluateScope::TerminateTask : public v8::Task { public: TerminateTask(v8::Isolate* isolate, std::shared_ptr token) - : m_isolate(isolate), m_token(token) {} + : m_isolate(isolate), m_token(std::move(token)) {} void Run() { // CancelToken contains m_canceled bool which may be changed from main diff --git a/src/inspector/v8-inspector-impl.h b/src/inspector/v8-inspector-impl.h index 2124ba6250..70eaf0eb20 100644 --- a/src/inspector/v8-inspector-impl.h +++ b/src/inspector/v8-inspector-impl.h @@ -120,9 +120,10 @@ class V8InspectorImpl : public V8Inspector { InspectedContext* getContext(int contextId) const; V8Console* console(); void forEachContext(int contextGroupId, - std::function callback); - void forEachSession(int contextGroupId, - std::function callback); + const std::function& callback); + void forEachSession( + int contextGroupId, + const std::function& callback); class EvaluateScope { public: diff --git a/src/inspector/v8-stack-trace-impl.cc b/src/inspector/v8-stack-trace-impl.cc index 21ca98d911..5c7ebbb678 100644 --- a/src/inspector/v8-stack-trace-impl.cc +++ b/src/inspector/v8-stack-trace-impl.cc @@ -223,7 +223,7 @@ V8StackTraceImpl::V8StackTraceImpl( const V8StackTraceId& externalParent) : m_frames(std::move(frames)), m_maxAsyncDepth(maxAsyncDepth), - m_asyncParent(asyncParent), + m_asyncParent(std::move(asyncParent)), m_externalParent(externalParent) {} V8StackTraceImpl::~V8StackTraceImpl() {} @@ -392,7 +392,7 @@ AsyncStackTrace::AsyncStackTrace( m_suspendedTaskId(nullptr), m_description(description), m_frames(std::move(frames)), - m_asyncParent(asyncParent), + m_asyncParent(std::move(asyncParent)), m_externalParent(externalParent) { DCHECK(m_contextGroupId || (!externalParent.IsInvalid() && m_frames.empty())); } diff --git a/src/inspector/wasm-translation.cc b/src/inspector/wasm-translation.cc index f049871202..3b6d32b6a1 100644 --- a/src/inspector/wasm-translation.cc +++ b/src/inspector/wasm-translation.cc @@ -62,7 +62,7 @@ class WasmTranslation::TranslatorImpl { TransLocation(WasmTranslation* translation, String16 script_id, int line, int column) : translation(translation), - script_id(script_id), + script_id(std::move(script_id)), line(line), column(column) {} }; @@ -238,7 +238,7 @@ class WasmTranslation::TranslatorImpl::DisassemblingTranslator return builder.toString(); } - String16 GetFakeScriptId(const String16 script_id, int func_index) { + String16 GetFakeScriptId(const String16& script_id, int func_index) { return String16::concat(script_id, '-', String16::fromInteger(func_index)); } String16 GetFakeScriptId(const TransLocation* loc) {