mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
perf: avoid unnecessary base value clone (#38564)
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user