perf: prefer NewFromUtf8Literal() over NewFromUtf8() for string literals (#44429)
* perf: prefer NewFromUtf8Literal() over NewFromUtf8() for string literals the string length is known at compile time and no need to call ToLocalChecked() Co-authored-by: Charles Kerr <charles@charleskerr.com> * perf: string length is known when calling NewFromUtf8(), so use it Co-authored-by: Charles Kerr <charles@charleskerr.com> * perf: remove unnecessary calls to c_str() these just force the code being called to have to recalculate the string length Co-authored-by: Charles Kerr <charles@charleskerr.com> --------- Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Charles Kerr <charles@charleskerr.com>
This commit is contained in:
parent
ec070e57e0
commit
a6b34dca26
4 changed files with 22 additions and 24 deletions
|
@ -122,11 +122,11 @@ void ElectronRendererClient::DidCreateScriptContext(
|
|||
"Headers"};
|
||||
for (const auto& key : keys) {
|
||||
v8::MaybeLocal<v8::Value> value =
|
||||
global->Get(renderer_context, gin::StringToV8(isolate, key.c_str()));
|
||||
global->Get(renderer_context, gin::StringToV8(isolate, key));
|
||||
if (!value.IsEmpty()) {
|
||||
std::string blink_key = "blink" + key;
|
||||
global
|
||||
->Set(renderer_context, gin::StringToV8(isolate, blink_key.c_str()),
|
||||
->Set(renderer_context, gin::StringToV8(isolate, blink_key),
|
||||
value.ToLocalChecked())
|
||||
.Check();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue