Skip to content

Commit

Permalink
src: use ToLocal in DeserializeProperties
Browse files Browse the repository at this point in the history
This commit uses ToLocal to avoid having to call ToLocalChecked.

PR-URL: #36279
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Daijiro Wachi <[email protected]>
  • Loading branch information
danbev authored and targos committed May 1, 2021
1 parent 2183a2b commit 685ed2c
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/env.cc
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,13 @@ void IsolateData::DeserializeProperties(const std::vector<size_t>* indexes) {
#define VS(PropertyName, StringValue) V(String, PropertyName)
#define V(TypeName, PropertyName) \
do { \
MaybeLocal<TypeName> field = \
MaybeLocal<TypeName> maybe_field = \
isolate_->GetDataFromSnapshotOnce<TypeName>((*indexes)[i++]); \
if (field.IsEmpty()) { \
Local<TypeName> field; \
if (!maybe_field.ToLocal(&field)) { \
fprintf(stderr, "Failed to deserialize " #PropertyName "\n"); \
} \
PropertyName##_.Set(isolate_, field.ToLocalChecked()); \
PropertyName##_.Set(isolate_, field); \
} while (0);
PER_ISOLATE_PRIVATE_SYMBOL_PROPERTIES(VP)
PER_ISOLATE_SYMBOL_PROPERTIES(VY)
Expand All @@ -108,12 +109,13 @@ void IsolateData::DeserializeProperties(const std::vector<size_t>* indexes) {
#undef VP

for (size_t j = 0; j < AsyncWrap::PROVIDERS_LENGTH; j++) {
MaybeLocal<String> field =
MaybeLocal<String> maybe_field =
isolate_->GetDataFromSnapshotOnce<String>((*indexes)[i++]);
if (field.IsEmpty()) {
Local<String> field;
if (!maybe_field.ToLocal(&field)) {
fprintf(stderr, "Failed to deserialize AsyncWrap provider %zu\n", j);
}
async_wrap_providers_[j].Set(isolate_, field.ToLocalChecked());
async_wrap_providers_[j].Set(isolate_, field);
}
}

Expand Down

0 comments on commit 685ed2c

Please sign in to comment.