Skip to content

Commit 803b0c4

Browse files
author
Daniel Lemire
committed
Light touch.
1 parent 6537d0d commit 803b0c4

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

include/simdjson/inline/parser.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,14 +151,20 @@ 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+
// It is possible that we change max_depth without touching capacity, in
155+
// 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+
}
154160
if (implementation) {
155161
err = implementation->allocate(capacity, max_depth);
156162
} else {
157163
err = simdjson::active_implementation->create_dom_parser_implementation(capacity, max_depth, implementation);
158164
}
159165
if (err) { return err; }
160166

161-
return doc.allocate(capacity);
167+
return SUCCESS;
162168
}
163169

164170
WARN_UNUSED

0 commit comments

Comments
 (0)