perf: prefer NewFromUtf8Literal() over NewFromUtf8() for string literals (#44427)
* 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
2138b5a3e0
commit
1a2015c87d
4 changed files with 22 additions and 24 deletions
|
@ -18,8 +18,7 @@ class Archive : public node::ObjectWrap {
|
|||
static v8::Local<v8::FunctionTemplate> CreateFunctionTemplate(
|
||||
v8::Isolate* isolate) {
|
||||
auto tpl = v8::FunctionTemplate::New(isolate, Archive::New);
|
||||
tpl->SetClassName(
|
||||
v8::String::NewFromUtf8(isolate, "Archive").ToLocalChecked());
|
||||
tpl->SetClassName(v8::String::NewFromUtf8Literal(isolate, "Archive"));
|
||||
tpl->InstanceTemplate()->SetInternalFieldCount(1);
|
||||
|
||||
NODE_SET_PROTOTYPE_METHOD(tpl, "getFileInfo", &Archive::GetFileInfo);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue