Skip to content

Commit 5cdd945

Browse files
backespthier
authored andcommitted
Avoid deprecated GetIsolate methods (#219)
These methods already return the value read from TLS. They will be deprecated and removed soon, so switch to using TLS directly.
1 parent a02c8ca commit 5cdd945

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/util-inl.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -327,14 +327,14 @@ v8::Maybe<void> FromV8Array(v8::Local<v8::Context> context,
327327
std::vector<v8::Global<v8::Value>>* out) {
328328
uint32_t count = js_array->Length();
329329
out->reserve(count);
330-
ArrayIterationData data{out, context->GetIsolate()};
330+
ArrayIterationData data{out, v8::Isolate::GetCurrent()};
331331
return js_array->Iterate(context, PushItemToVector, &data);
332332
}
333333

334334
v8::MaybeLocal<v8::Value> ToV8Value(v8::Local<v8::Context> context,
335335
std::string_view str,
336336
v8::Isolate* isolate) {
337-
if (isolate == nullptr) isolate = context->GetIsolate();
337+
if (isolate == nullptr) isolate = v8::Isolate::GetCurrent();
338338
if (str.size() >= static_cast<size_t>(v8::String::kMaxLength)) [[unlikely]] {
339339
// V8 only has a TODO comment about adding an exception when the maximum
340340
// string size is exceeded.
@@ -350,7 +350,7 @@ v8::MaybeLocal<v8::Value> ToV8Value(v8::Local<v8::Context> context,
350350
v8::MaybeLocal<v8::Value> ToV8Value(v8::Local<v8::Context> context,
351351
v8_inspector::StringView str,
352352
v8::Isolate* isolate) {
353-
if (isolate == nullptr) isolate = context->GetIsolate();
353+
if (isolate == nullptr) isolate = v8::Isolate::GetCurrent();
354354
if (str.length() >= static_cast<size_t>(v8::String::kMaxLength))
355355
[[unlikely]] {
356356
// V8 only has a TODO comment about adding an exception when the maximum
@@ -377,7 +377,7 @@ template <typename T>
377377
v8::MaybeLocal<v8::Value> ToV8Value(v8::Local<v8::Context> context,
378378
const std::vector<T>& vec,
379379
v8::Isolate* isolate) {
380-
if (isolate == nullptr) isolate = context->GetIsolate();
380+
if (isolate == nullptr) isolate = v8::Isolate::GetCurrent();
381381
v8::EscapableHandleScope handle_scope(isolate);
382382

383383
MaybeStackBuffer<v8::Local<v8::Value>, 128> arr(vec.size());
@@ -394,7 +394,7 @@ template <typename T>
394394
v8::MaybeLocal<v8::Value> ToV8Value(v8::Local<v8::Context> context,
395395
const std::set<T>& set,
396396
v8::Isolate* isolate) {
397-
if (isolate == nullptr) isolate = context->GetIsolate();
397+
if (isolate == nullptr) isolate = v8::Isolate::GetCurrent();
398398
v8::Local<v8::Set> set_js = v8::Set::New(isolate);
399399
v8::HandleScope handle_scope(isolate);
400400

@@ -413,7 +413,7 @@ template <typename T, std::size_t U>
413413
v8::MaybeLocal<v8::Value> ToV8Value(v8::Local<v8::Context> context,
414414
const std::ranges::elements_view<T, U>& vec,
415415
v8::Isolate* isolate) {
416-
if (isolate == nullptr) isolate = context->GetIsolate();
416+
if (isolate == nullptr) isolate = v8::Isolate::GetCurrent();
417417
v8::EscapableHandleScope handle_scope(isolate);
418418

419419
MaybeStackBuffer<v8::Local<v8::Value>, 128> arr(vec.size());
@@ -432,7 +432,7 @@ template <typename T, typename U>
432432
v8::MaybeLocal<v8::Value> ToV8Value(v8::Local<v8::Context> context,
433433
const std::unordered_map<T, U>& map,
434434
v8::Isolate* isolate) {
435-
if (isolate == nullptr) isolate = context->GetIsolate();
435+
if (isolate == nullptr) isolate = v8::Isolate::GetCurrent();
436436
v8::EscapableHandleScope handle_scope(isolate);
437437

438438
v8::Local<v8::Map> ret = v8::Map::New(isolate);
@@ -475,7 +475,7 @@ template <typename T, typename>
475475
v8::MaybeLocal<v8::Value> ToV8Value(v8::Local<v8::Context> context,
476476
const T& number,
477477
v8::Isolate* isolate) {
478-
if (isolate == nullptr) isolate = context->GetIsolate();
478+
if (isolate == nullptr) isolate = v8::Isolate::GetCurrent();
479479
return ConvertNumberToV8Value(isolate, number);
480480
}
481481

@@ -488,7 +488,7 @@ v8::Local<v8::Array> ToV8ValuePrimitiveArray(v8::Local<v8::Context> context,
488488
std::is_floating_point_v<T>,
489489
"Only primitive types (bool, integral, floating-point) are supported.");
490490

491-
if (isolate == nullptr) isolate = context->GetIsolate();
491+
if (isolate == nullptr) isolate = v8::Isolate::GetCurrent();
492492
v8::EscapableHandleScope handle_scope(isolate);
493493

494494
v8::LocalVector<v8::Value> elements(isolate);

0 commit comments

Comments
 (0)