Skip to content

Commit 59aef2d

Browse files
committed
src: remove ToLocalChecked() from UnionBytes
1 parent b13f24c commit 59aef2d

File tree

3 files changed

+18
-10
lines changed

3 files changed

+18
-10
lines changed

src/node_builtins.cc

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,23 @@ void BuiltinLoader::GetNatives(Local<Name> property,
9090
auto source = env->builtin_loader()->source_.read();
9191
for (auto const& x : *source) {
9292
Local<String> key = OneByteString(isolate, x.first);
93-
if (out->Set(context, key, x.second.ToStringChecked(isolate)).IsNothing()) {
93+
Local<String> value;
94+
if (!x.second.ToString(isolate).ToLocal(&value)) {
95+
return;
96+
}
97+
if (out->Set(context, key, value).IsNothing()) {
9498
return;
9599
}
96100
}
97101
info.GetReturnValue().Set(out);
98102
}
99103

100104
Local<String> BuiltinLoader::GetConfigString(Isolate* isolate) {
101-
return config_.ToStringChecked(isolate);
105+
Local<String> config_str;
106+
if (!config_.ToString(isolate).ToLocal(&config_str)) {
107+
return {};
108+
}
109+
return config_str;
102110
}
103111

104112
BuiltinLoader::BuiltinCategories BuiltinLoader::GetBuiltinCategories() const {
@@ -203,7 +211,7 @@ MaybeLocal<String> BuiltinLoader::LoadBuiltinSource(Isolate* isolate,
203211
fprintf(stderr, "Cannot find native builtin: \"%s\".\n", id);
204212
ABORT();
205213
}
206-
return source_it->second.ToStringChecked(isolate);
214+
return source_it->second.ToString(isolate);
207215
#else // !NODE_BUILTIN_MODULES_PATH
208216
std::string filename = OnDiskFileName(id);
209217

src/node_union_bytes.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ using StaticExternalTwoByteResource =
5252

5353
// Similar to a v8::String, but it's independent from Isolates
5454
// and can be materialized in Isolates as external Strings
55-
// via ToStringChecked.
55+
// via ToString.
5656
class UnionBytes {
5757
public:
5858
explicit UnionBytes(StaticExternalOneByteResource* one_byte_resource)
@@ -67,7 +67,7 @@ class UnionBytes {
6767

6868
bool is_one_byte() const { return one_byte_resource_ != nullptr; }
6969

70-
v8::Local<v8::String> ToStringChecked(v8::Isolate* isolate) const;
70+
v8::MaybeLocal<v8::String> ToString(v8::Isolate* isolate) const;
7171

7272
private:
7373
StaticExternalOneByteResource* one_byte_resource_;

src/util.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include "node_snapshot_builder.h"
3333
#include "node_v8_platform-inl.h"
3434
#include "string_bytes.h"
35+
#include "v8-local-handle.h"
3536
#include "v8-value.h"
3637

3738
#ifdef _WIN32
@@ -91,6 +92,7 @@ using v8::Context;
9192
using v8::FunctionTemplate;
9293
using v8::Isolate;
9394
using v8::Local;
95+
using v8::MaybeLocal;
9496
using v8::Object;
9597
using v8::String;
9698
using v8::Template;
@@ -725,13 +727,11 @@ void SetConstructorFunction(Isolate* isolate,
725727
that->Set(name, tmpl);
726728
}
727729

728-
Local<String> UnionBytes::ToStringChecked(Isolate* isolate) const {
730+
MaybeLocal<String> UnionBytes::ToString(Isolate* isolate) const {
729731
if (is_one_byte()) {
730-
return String::NewExternalOneByte(isolate, one_byte_resource_)
731-
.ToLocalChecked();
732+
return String::NewExternalOneByte(isolate, one_byte_resource_);
732733
} else {
733-
return String::NewExternalTwoByte(isolate, two_byte_resource_)
734-
.ToLocalChecked();
734+
return String::NewExternalTwoByte(isolate, two_byte_resource_);
735735
}
736736
}
737737

0 commit comments

Comments
 (0)