-
-
Notifications
You must be signed in to change notification settings - Fork 34.3k
src: remove ToLocalChecked() from UnionBytes
#60164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -90,15 +90,23 @@ void BuiltinLoader::GetNatives(Local<Name> property, | |
| auto source = env->builtin_loader()->source_.read(); | ||
| for (auto const& x : *source) { | ||
| Local<String> key = OneByteString(isolate, x.first); | ||
| if (out->Set(context, key, x.second.ToStringChecked(isolate)).IsNothing()) { | ||
| Local<String> value; | ||
| if (!x.second.ToString(isolate).ToLocal(&value)) { | ||
| return; | ||
| } | ||
| if (out->Set(context, key, value).IsNothing()) { | ||
| return; | ||
| } | ||
| } | ||
| info.GetReturnValue().Set(out); | ||
| } | ||
|
|
||
| Local<String> BuiltinLoader::GetConfigString(Isolate* isolate) { | ||
| return config_.ToStringChecked(isolate); | ||
| Local<String> config_str; | ||
| if (!config_.ToString(isolate).ToLocal(&config_str)) { | ||
| return {}; | ||
| } | ||
| return config_str; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's not do this – this is dangerous and strictly worse than the previous code, because a return type of |
||
| } | ||
|
|
||
| BuiltinLoader::BuiltinCategories BuiltinLoader::GetBuiltinCategories() const { | ||
|
|
@@ -203,7 +211,7 @@ MaybeLocal<String> BuiltinLoader::LoadBuiltinSource(Isolate* isolate, | |
| fprintf(stderr, "Cannot find native builtin: \"%s\".\n", id); | ||
| ABORT(); | ||
| } | ||
| return source_it->second.ToStringChecked(isolate); | ||
| return source_it->second.ToString(isolate); | ||
| #else // !NODE_BUILTIN_MODULES_PATH | ||
| std::string filename = OnDiskFileName(id); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -32,6 +32,7 @@ | |||||||||||||||||||||||
| #include "node_snapshot_builder.h" | ||||||||||||||||||||||||
| #include "node_v8_platform-inl.h" | ||||||||||||||||||||||||
| #include "string_bytes.h" | ||||||||||||||||||||||||
| #include "v8-local-handle.h" | ||||||||||||||||||||||||
| #include "v8-value.h" | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| #ifdef _WIN32 | ||||||||||||||||||||||||
|
|
@@ -91,6 +92,7 @@ using v8::Context; | |||||||||||||||||||||||
| using v8::FunctionTemplate; | ||||||||||||||||||||||||
| using v8::Isolate; | ||||||||||||||||||||||||
| using v8::Local; | ||||||||||||||||||||||||
| using v8::MaybeLocal; | ||||||||||||||||||||||||
| using v8::Object; | ||||||||||||||||||||||||
| using v8::String; | ||||||||||||||||||||||||
| using v8::Template; | ||||||||||||||||||||||||
|
|
@@ -725,13 +727,11 @@ void SetConstructorFunction(Isolate* isolate, | |||||||||||||||||||||||
| that->Set(name, tmpl); | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| Local<String> UnionBytes::ToStringChecked(Isolate* isolate) const { | ||||||||||||||||||||||||
| MaybeLocal<String> UnionBytes::ToString(Isolate* isolate) const { | ||||||||||||||||||||||||
| if (is_one_byte()) { | ||||||||||||||||||||||||
| return String::NewExternalOneByte(isolate, one_byte_resource_) | ||||||||||||||||||||||||
| .ToLocalChecked(); | ||||||||||||||||||||||||
| return String::NewExternalOneByte(isolate, one_byte_resource_); | ||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||
| return String::NewExternalTwoByte(isolate, two_byte_resource_) | ||||||||||||||||||||||||
| .ToLocalChecked(); | ||||||||||||||||||||||||
| return String::NewExternalTwoByte(isolate, two_byte_resource_); | ||||||||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change kind of only brings us halfway towards the right semantics, because the comment in this snippet also applies here: Lines 347 to 357 in 1527825
|
||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a suggestion, but if we add support for
UnionBytesinToV8Value(), this entirely loop could be replaced by aToV8Value()call