File tree Expand file tree Collapse file tree 1 file changed +8
-8
lines changed
Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Original file line number Diff line number Diff line change @@ -44,9 +44,11 @@ using v8::Null;
4444using v8::Number;
4545using v8::Object;
4646using v8::Primitive;
47+ using v8::Array;
4748using v8::String;
4849using v8::Undefined;
4950using v8::Value;
51+ using v8::LocalVector;
5052
5153template <typename T>
5254inline MaybeLocal<Value> ToV8Number (Isolate* isolate,
@@ -107,23 +109,21 @@ MaybeLocal<Value> ConvertSimdjsonElement(Isolate* isolate,
107109
108110 THROW_AND_RETURN_EMPTY_IF_SIMDJSON_ERROR (isolate, error);
109111
110- Local<Array> v8_array =
111- v8::Array::New (isolate, array.size ());
112-
113- Local<Context> context = isolate->GetCurrentContext ();
112+ size_t size = array.size ();
113+ LocalVector<Value> elements (isolate);
114+ elements.reserve (size);
114115
115- uint32_t index = 0 ;
116116 for (simdjson::dom::element child : array) {
117117 Local<Value> converted;
118118
119119 if (!ConvertSimdjsonElement (isolate, child).ToLocal (&converted))
120120 return MaybeLocal<Value>();
121121
122- if (v8_array->Set (context, index, converted).IsNothing ())
123- return MaybeLocal<Value>();
124- index++;
122+ elements.push_back (converted);
125123 }
126124
125+ Local<Array> v8_array = Array::New (isolate, elements.data (), size);
126+
127127 return MaybeLocal<Value>(v8_array);
128128 }
129129 case simdjson::dom::element_type::OBJECT: {
You can’t perform that action at this time.
0 commit comments