Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
src: use NewFromUtf8Literal in NODE_DEFINE_CONSTANT
Small efficiency improvement over NewFromUtf8(): the literal's
length is known at compile time, so V8 doesn't have to call
strlen() or ToLocalChecked().
  • Loading branch information
ckerr committed Oct 28, 2024
commit 943b125ec074a8919d7bacdf75541296ac72b4d6
9 changes: 4 additions & 5 deletions src/node.h
Original file line number Diff line number Diff line change
Expand Up @@ -1028,8 +1028,8 @@ NODE_DEPRECATED("Use v8::Date::ValueOf() directly",
v8::Isolate* isolate = target->GetIsolate(); \
v8::Local<v8::Context> context = isolate->GetCurrentContext(); \
v8::Local<v8::String> constant_name = \
v8::String::NewFromUtf8(isolate, #constant, \
v8::NewStringType::kInternalized).ToLocalChecked(); \
v8::String::NewFromUtf8Literal(isolate, #constant, \
v8::NewStringType::kInternalized); \
v8::Local<v8::Number> constant_value = \
v8::Number::New(isolate, static_cast<double>(constant)); \
v8::PropertyAttribute constant_attributes = \
Expand All @@ -1046,9 +1046,8 @@ NODE_DEPRECATED("Use v8::Date::ValueOf() directly",
v8::Isolate* isolate = target->GetIsolate(); \
v8::Local<v8::Context> context = isolate->GetCurrentContext(); \
v8::Local<v8::String> constant_name = \
v8::String::NewFromUtf8(isolate, #constant, \
v8::NewStringType::kInternalized) \
.ToLocalChecked(); \
v8::String::NewFromUtf8Literal(isolate, #constant, \
v8::NewStringType::kInternalized); \
v8::Local<v8::Number> constant_value = \
v8::Number::New(isolate, static_cast<double>(constant)); \
v8::PropertyAttribute constant_attributes = \
Expand Down