perf: prefer NewFromUtf8Literal() over NewFromUtf8() for string literals (#44428)
* 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
ed3cbb12e3
commit
c3321715e3
4 changed files with 22 additions and 24 deletions
|
@ -57,7 +57,7 @@ v8::Local<v8::Value> GetBinding(v8::Isolate* isolate,
|
|||
std::string binding_key = gin::V8ToString(isolate, key);
|
||||
gin_helper::Dictionary cache(isolate, GetBindingCache(isolate));
|
||||
|
||||
if (cache.Get(binding_key.c_str(), &exports)) {
|
||||
if (cache.Get(binding_key, &exports)) {
|
||||
return exports;
|
||||
}
|
||||
|
||||
|
@ -76,7 +76,7 @@ v8::Local<v8::Value> GetBinding(v8::Isolate* isolate,
|
|||
DCHECK_NE(mod->nm_context_register_func, nullptr);
|
||||
mod->nm_context_register_func(exports, v8::Null(isolate),
|
||||
isolate->GetCurrentContext(), mod->nm_priv);
|
||||
cache.Set(binding_key.c_str(), exports);
|
||||
cache.Set(binding_key, exports);
|
||||
return exports;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue