From 25f2abb64d911102224f5bf93267bd49ae1eac9f Mon Sep 17 00:00:00 2001 From: Darshan Sen Date: Tue, 16 Nov 2021 13:45:32 +0530 Subject: [PATCH] chore: use `std::forward()` in `ConvertToV8()` (#31817) The variable `input` is accepted by a universal reference, so it doesn't make sense to cast a potential lvalue reference into an rvalue reference. In case `input` is an lvalue reference, we should rather forward the value as is to `ToV8()`. Signed-off-by: Darshan Sen --- shell/common/gin_converters/std_converter.h | 2 +- shell/renderer/api/electron_api_context_bridge.cc | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/shell/common/gin_converters/std_converter.h b/shell/common/gin_converters/std_converter.h index 1230334e6f10..eb5f87d22e3d 100644 --- a/shell/common/gin_converters/std_converter.h +++ b/shell/common/gin_converters/std_converter.h @@ -21,7 +21,7 @@ namespace gin { template v8::Local ConvertToV8(v8::Isolate* isolate, T&& input) { return Converter::type>::ToV8( - isolate, std::move(input)); + isolate, std::forward(input)); } #if !defined(OS_LINUX) && !defined(OS_FREEBSD) diff --git a/shell/renderer/api/electron_api_context_bridge.cc b/shell/renderer/api/electron_api_context_bridge.cc index ef3a130fcabf..c937c616b276 100644 --- a/shell/renderer/api/electron_api_context_bridge.cc +++ b/shell/renderer/api/electron_api_context_bridge.cc @@ -282,9 +282,9 @@ v8::MaybeLocal PassValueToOtherContext( ignore_result(source_promise->Then( source_context, - gin::ConvertToV8(destination_context->GetIsolate(), then_cb) + gin::ConvertToV8(destination_context->GetIsolate(), std::move(then_cb)) .As(), - gin::ConvertToV8(destination_context->GetIsolate(), catch_cb) + gin::ConvertToV8(destination_context->GetIsolate(), std::move(catch_cb)) .As())); object_cache->CacheProxiedObject(value, proxied_promise_handle);