Skip to content

Commit

Permalink
chore: use std::forward() in ConvertToV8() (#31858)
Browse files Browse the repository at this point in the history
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 <darshan.sen@postman.com>

Co-authored-by: Darshan Sen <darshan.sen@postman.com>
  • Loading branch information
trop[bot] and RaisinTen committed Nov 16, 2021
1 parent dae2246 commit 358bffb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion shell/common/gin_converters/std_converter.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace gin {
template <typename T>
v8::Local<v8::Value> ConvertToV8(v8::Isolate* isolate, T&& input) {
return Converter<typename std::remove_reference<T>::type>::ToV8(
isolate, std::move(input));
isolate, std::forward<T>(input));
}

#if !defined(OS_LINUX) && !defined(OS_FREEBSD)
Expand Down
4 changes: 2 additions & 2 deletions shell/renderer/api/electron_api_context_bridge.cc
Original file line number Diff line number Diff line change
Expand Up @@ -281,9 +281,9 @@ v8::MaybeLocal<v8::Value> 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<v8::Function>(),
gin::ConvertToV8(destination_context->GetIsolate(), catch_cb)
gin::ConvertToV8(destination_context->GetIsolate(), std::move(catch_cb))
.As<v8::Function>()));

object_cache->CacheProxiedObject(value, proxied_promise_handle);
Expand Down

0 comments on commit 358bffb

Please sign in to comment.