File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -151,19 +151,23 @@ inline error_code parser::allocate(size_t capacity, size_t max_depth) noexcept {
151151 // Reallocate implementation and document if needed
152152 //
153153 error_code err;
154+ //
154155 // It is possible that we change max_depth without touching capacity, in
155156 // which case, we do not want to reallocate the document buffers.
156- if (implementation->capacity () != capacity || !doc.tape ) {
157- err = doc.allocate (capacity);
158- if (err) { return err; }
159- }
157+ //
158+ bool need_doc_allocation{false };
160159 if (implementation) {
160+ need_doc_allocation = implementation->capacity () != capacity || !doc.tape ;
161161 err = implementation->allocate (capacity, max_depth);
162162 } else {
163+ need_doc_allocation = true ;
163164 err = simdjson::active_implementation->create_dom_parser_implementation (capacity, max_depth, implementation);
164165 }
165166 if (err) { return err; }
166-
167+ if (need_doc_allocation) {
168+ err = doc.allocate (capacity);
169+ if (err) { return err; }
170+ }
167171 return SUCCESS ;
168172}
169173
You can’t perform that action at this time.
0 commit comments