From 6a4d9309b25510f49afe54b26ca81f98af55df92 Mon Sep 17 00:00:00 2001 From: Milan Burda Date: Tue, 15 May 2018 16:21:23 +0200 Subject: [PATCH] Remove unnecessary heap allocations of atom::V8ValueConverter instances (#12924) --- .../native_mate_converters/value_converter.cc | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/atom/common/native_mate_converters/value_converter.cc b/atom/common/native_mate_converters/value_converter.cc index 769965f6445b..552c598b24ca 100644 --- a/atom/common/native_mate_converters/value_converter.cc +++ b/atom/common/native_mate_converters/value_converter.cc @@ -12,9 +12,9 @@ namespace mate { bool Converter::FromV8(v8::Isolate* isolate, v8::Local val, base::DictionaryValue* out) { - std::unique_ptr converter(new atom::V8ValueConverter); + atom::V8ValueConverter converter; std::unique_ptr value( - converter->FromV8Value(val, isolate->GetCurrentContext())); + converter.FromV8Value(val, isolate->GetCurrentContext())); if (value && value->IsType(base::Value::Type::DICTIONARY)) { out->Swap(static_cast(value.get())); return true; @@ -26,16 +26,16 @@ bool Converter::FromV8(v8::Isolate* isolate, v8::Local Converter::ToV8( v8::Isolate* isolate, const base::DictionaryValue& val) { - std::unique_ptr converter(new atom::V8ValueConverter); - return converter->ToV8Value(&val, isolate->GetCurrentContext()); + atom::V8ValueConverter converter; + return converter.ToV8Value(&val, isolate->GetCurrentContext()); } bool Converter::FromV8(v8::Isolate* isolate, v8::Local val, base::ListValue* out) { - std::unique_ptr converter(new atom::V8ValueConverter); + atom::V8ValueConverter converter; std::unique_ptr value( - converter->FromV8Value(val, isolate->GetCurrentContext())); + converter.FromV8Value(val, isolate->GetCurrentContext())); if (value->IsType(base::Value::Type::LIST)) { out->Swap(static_cast(value.get())); return true; @@ -47,8 +47,8 @@ bool Converter::FromV8(v8::Isolate* isolate, v8::Local Converter::ToV8( v8::Isolate* isolate, const base::ListValue& val) { - std::unique_ptr converter(new atom::V8ValueConverter); - return converter->ToV8Value(&val, isolate->GetCurrentContext()); + atom::V8ValueConverter converter; + return converter.ToV8Value(&val, isolate->GetCurrentContext()); } } // namespace mate