perf: avoid unnecessary base value clone (#38537)
This commit is contained in:
parent
d818f35ad4
commit
f247ca3f62
6 changed files with 23 additions and 28 deletions
|
@ -22,7 +22,7 @@ v8::Local<v8::Value> Converter<const extensions::Extension*>::ToV8(
|
|||
dict.Set("path", extension->path());
|
||||
dict.Set("url", extension->url());
|
||||
dict.Set("version", extension->VersionString());
|
||||
dict.Set("manifest", extension->manifest()->value()->Clone());
|
||||
dict.Set("manifest", *extension->manifest()->value());
|
||||
|
||||
return gin::ConvertToV8(isolate, dict);
|
||||
}
|
||||
|
|
|
@ -25,14 +25,6 @@ bool Converter<base::Value::Dict>::FromV8(v8::Isolate* isolate,
|
|||
}
|
||||
}
|
||||
|
||||
v8::Local<v8::Value> Converter<base::Value::Dict>::ToV8(
|
||||
v8::Isolate* isolate,
|
||||
const base::Value::Dict& val) {
|
||||
base::Value value(val.Clone());
|
||||
return content::V8ValueConverter::Create()->ToV8Value(
|
||||
value, isolate->GetCurrentContext());
|
||||
}
|
||||
|
||||
bool Converter<base::Value>::FromV8(v8::Isolate* isolate,
|
||||
v8::Local<v8::Value> val,
|
||||
base::Value* out) {
|
||||
|
@ -47,8 +39,9 @@ bool Converter<base::Value>::FromV8(v8::Isolate* isolate,
|
|||
}
|
||||
}
|
||||
|
||||
v8::Local<v8::Value> Converter<base::Value>::ToV8(v8::Isolate* isolate,
|
||||
const base::Value& val) {
|
||||
v8::Local<v8::Value> Converter<base::ValueView>::ToV8(
|
||||
v8::Isolate* isolate,
|
||||
const base::ValueView val) {
|
||||
return content::V8ValueConverter::Create()->ToV8Value(
|
||||
val, isolate->GetCurrentContext());
|
||||
}
|
||||
|
@ -67,12 +60,4 @@ bool Converter<base::Value::List>::FromV8(v8::Isolate* isolate,
|
|||
}
|
||||
}
|
||||
|
||||
v8::Local<v8::Value> Converter<base::Value::List>::ToV8(
|
||||
v8::Isolate* isolate,
|
||||
const base::Value::List& val) {
|
||||
base::Value value(val.Clone());
|
||||
return content::V8ValueConverter::Create()->ToV8Value(
|
||||
value, isolate->GetCurrentContext());
|
||||
}
|
||||
|
||||
} // namespace gin
|
||||
|
|
|
@ -10,13 +10,21 @@
|
|||
|
||||
namespace gin {
|
||||
|
||||
template <>
|
||||
struct Converter<base::ValueView> {
|
||||
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
|
||||
const base::ValueView val);
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Converter<base::Value::Dict> {
|
||||
static bool FromV8(v8::Isolate* isolate,
|
||||
v8::Local<v8::Value> val,
|
||||
base::Value::Dict* out);
|
||||
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
|
||||
const base::Value::Dict& val);
|
||||
const base::Value::Dict& val) {
|
||||
return gin::ConvertToV8(isolate, base::ValueView{val});
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
|
@ -25,7 +33,9 @@ struct Converter<base::Value> {
|
|||
v8::Local<v8::Value> val,
|
||||
base::Value* out);
|
||||
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
|
||||
const base::Value& val);
|
||||
const base::Value& val) {
|
||||
return gin::ConvertToV8(isolate, base::ValueView{val});
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
|
@ -34,7 +44,9 @@ struct Converter<base::Value::List> {
|
|||
v8::Local<v8::Value> val,
|
||||
base::Value::List* out);
|
||||
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
|
||||
const base::Value::List& val);
|
||||
const base::Value::List& val) {
|
||||
return gin::ConvertToV8(isolate, base::ValueView{val});
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace gin
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue