зеркало из https://github.com/electron/electron.git
refactor: use base::Value::Take*() (#41169)
* perf: avoid temporary strings in Converter<net::HttpRequestHeaders>::FromV8() * perf: take strings instead of copying them in ToResponseHead() * refactor: prefer base::Value::Take*() where appropriate As per the base::Value docs: "prefer over `std::move(value.Get...())` so clang-tidy can warn about potential use-after-move mistakes."
This commit is contained in:
Родитель
88f28a302f
Коммит
10fd0ba655
|
@ -103,7 +103,7 @@ std::unique_ptr<base::Value::Dict> ParseManifest(
|
||||||
LOG(ERROR) << "Failed to parse extension manifest.";
|
LOG(ERROR) << "Failed to parse extension manifest.";
|
||||||
return std::unique_ptr<base::Value::Dict>();
|
return std::unique_ptr<base::Value::Dict>();
|
||||||
}
|
}
|
||||||
return std::make_unique<base::Value::Dict>(std::move(manifest->GetDict()));
|
return std::make_unique<base::Value::Dict>(std::move(*manifest).TakeDict());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ElectronExtensionSystem::LoadComponentExtensions() {
|
void ElectronExtensionSystem::LoadComponentExtensions() {
|
||||||
|
|
|
@ -270,7 +270,7 @@ bool Archive::Init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
header_size_ = 8 + size;
|
header_size_ = 8 + size;
|
||||||
header_ = std::move(value->GetDict());
|
header_ = std::move(*value).TakeDict();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -244,10 +244,8 @@ bool Converter<net::HttpRequestHeaders>::FromV8(v8::Isolate* isolate,
|
||||||
if (!ConvertFromV8(isolate, val, &dict))
|
if (!ConvertFromV8(isolate, val, &dict))
|
||||||
return false;
|
return false;
|
||||||
for (const auto it : dict) {
|
for (const auto it : dict) {
|
||||||
if (it.second.is_string()) {
|
if (it.second.is_string())
|
||||||
std::string value = it.second.GetString();
|
out->SetHeader(it.first, std::move(it.second).TakeString());
|
||||||
out->SetHeader(it.first, value);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ bool Converter<base::Value::Dict>::FromV8(v8::Isolate* isolate,
|
||||||
content::V8ValueConverter::Create()->FromV8Value(
|
content::V8ValueConverter::Create()->FromV8Value(
|
||||||
val, isolate->GetCurrentContext());
|
val, isolate->GetCurrentContext());
|
||||||
if (value && value->is_dict()) {
|
if (value && value->is_dict()) {
|
||||||
*out = std::move(value->GetDict());
|
*out = std::move(*value).TakeDict();
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
@ -53,7 +53,7 @@ bool Converter<base::Value::List>::FromV8(v8::Isolate* isolate,
|
||||||
content::V8ValueConverter::Create()->FromV8Value(
|
content::V8ValueConverter::Create()->FromV8Value(
|
||||||
val, isolate->GetCurrentContext());
|
val, isolate->GetCurrentContext());
|
||||||
if (value && value->is_list()) {
|
if (value && value->is_list()) {
|
||||||
*out = std::move(value->GetList());
|
*out = std::move(*value).TakeList();
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче