| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent bb1aea8 commit 8d2858a
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -15,6 +15,7 @@ using v8::FunctionCallbackInfo; | |||
| 15 | 15 | using v8::Isolate; | |
| 16 | 16 | using v8::Local; | |
| 17 | 17 | using v8::LocalVector; | |
| 18 | + using v8::MaybeLocal; | ||
| 18 | 19 | using v8::NewStringType; | |
| 19 | 20 | using v8::Object; | |
| 20 | 21 | using v8::Set; | |
@@ -23,22 +24,20 @@ using v8::Value; | |||
| 23 | 24 | ||
| 24 | 25 | // Create a V8 string from an export_string variant, using fast path for ASCII | |
| 25 | 26 | template <typename T> | |
| 26 | - inline Local<String> CreateString(Isolate* isolate, const T& str) { | ||
| 27 | + inline MaybeLocal<String> CreateString(Isolate* isolate, const T& str) { | ||
| 27 | 28 | std::string_view sv = lexer::get_string_view(str); | |
| 28 | 29 | ||
| 29 | 30 | if (simdutf::validate_ascii(sv.data(), sv.size())) { | |
| 30 | 31 | return String::NewFromOneByte(isolate, | |
| 31 | 32 | reinterpret_cast<const uint8_t*>(sv.data()), | |
| 32 | 33 | NewStringType::kInternalized, | |
| 33 | - static_cast<int>(sv.size())) | ||
| 34 | - .ToLocalChecked(); | ||
| 34 | + static_cast<int>(sv.size())); | ||
| 35 | 35 | } | |
| 36 | 36 | ||
| 37 | 37 | return String::NewFromUtf8(isolate, | |
| 38 | 38 | sv.data(), | |
| 39 | 39 | NewStringType::kInternalized, | |
| 40 | - static_cast<int>(sv.size())) | ||
| 41 | - .ToLocalChecked(); | ||
| 40 | + static_cast<int>(sv.size())); | ||
| 42 | 41 | } | |
| 43 | 42 | ||
| 44 | 43 | void Parse(const FunctionCallbackInfo<Value>& args) { | |
@@ -71,14 +70,22 @@ void Parse(const FunctionCallbackInfo<Value>& args) { | |||
| 71 | 70 | // Convert exports to JS Set | |
| 72 | 71 | Local<Set> exports_set = Set::New(isolate); | |
| 73 | 72 | for (const auto& exp : analysis.exports) { | |
| 74 | - exports_set->Add(context, CreateString(isolate, exp)).ToLocalChecked(); | ||
| 73 | + Local<String> exp_str; | ||
| 74 | + if (!CreateString(isolate, exp).ToLocal(&exp_str) || | ||
| 75 | + exports_set->Add(context, exp_str).IsEmpty()) { | ||
| 76 | + return; | ||
| 77 | + } | ||
| 75 | 78 | } | |
| 76 | 79 | ||
| 77 | 80 | // Convert reexports to JS array using batch creation | |
| 78 | 81 | LocalVector<Value> reexports_vec(isolate); | |
| 79 | 82 | reexports_vec.reserve(analysis.re_exports.size()); | |
| 80 | 83 | for (const auto& reexp : analysis.re_exports) { | |
| 81 | - reexports_vec.push_back(CreateString(isolate, reexp)); | ||
| 84 | + Local<String> reexp_str; | ||
| 85 | + if (!CreateString(isolate, reexp).ToLocal(&reexp_str)) { | ||
| 86 | + return; | ||
| 87 | + } | ||
| 88 | + reexports_vec.push_back(reexp_str); | ||
| 82 | 89 | } | |
| 83 | 90 | ||
| 84 | 91 | // Create result array [exports (Set), reexports (Array)] | |
| Back | FazBrowse Home | New Git URL |
0 commit comments