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
|
@ -329,10 +329,8 @@ void ElectronBrowserContext::InitPrefs() {
|
|||
#endif
|
||||
|
||||
#if BUILDFLAG(ENABLE_BUILTIN_SPELLCHECKER)
|
||||
base::Value::List current_dictionaries =
|
||||
prefs()->GetList(spellcheck::prefs::kSpellCheckDictionaries).Clone();
|
||||
// No configured dictionaries, the default will be en-US
|
||||
if (current_dictionaries.empty()) {
|
||||
if (prefs()->GetList(spellcheck::prefs::kSpellCheckDictionaries).empty()) {
|
||||
std::string default_code = spellcheck::GetCorrespondingSpellCheckLanguage(
|
||||
base::i18n::GetConfiguredLocale());
|
||||
if (!default_code.empty()) {
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace electron {
|
|||
|
||||
NSArray* ListValueToNSArray(const base::Value::List& value) {
|
||||
std::string json;
|
||||
if (!base::JSONWriter::Write(base::Value(value.Clone()), &json))
|
||||
if (!base::JSONWriter::Write(base::ValueView{value}, &json))
|
||||
return nil;
|
||||
NSData* jsonData = [NSData dataWithBytes:json.c_str() length:json.length()];
|
||||
id obj = [NSJSONSerialization JSONObjectWithData:jsonData
|
||||
|
@ -57,7 +57,7 @@ base::Value::List NSArrayToValue(NSArray* arr) {
|
|||
|
||||
NSDictionary* DictionaryValueToNSDictionary(const base::Value::Dict& value) {
|
||||
std::string json;
|
||||
if (!base::JSONWriter::Write(base::Value(value.Clone()), &json))
|
||||
if (!base::JSONWriter::Write(base::ValueView{value}, &json))
|
||||
return nil;
|
||||
NSData* jsonData = [NSData dataWithBytes:json.c_str() length:json.length()];
|
||||
id obj = [NSJSONSerialization JSONObjectWithData:jsonData
|
||||
|
|
|
@ -206,7 +206,7 @@ void UsbChooserContext::RevokeObjectPermissionInternal(
|
|||
v8::HandleScope scope(isolate);
|
||||
gin_helper::Dictionary details =
|
||||
gin_helper::Dictionary::CreateEmpty(isolate);
|
||||
details.Set("device", object.Clone());
|
||||
details.Set("device", object);
|
||||
details.Set("origin", origin.Serialize());
|
||||
session->Emit("usb-device-revoked", details);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue