summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArseny Kapoulkine <arseny.kapoulkine@gmail.com>2017-11-13 19:10:36 -0800
committerArseny Kapoulkine <arseny.kapoulkine@gmail.com>2017-11-13 19:10:36 -0800
commit344c74a74c350f755d916ef6e6ac4b75160dcf86 (patch)
treef8b26872f0d44d764d53ca4323f77a1e2285a988
parent7c6d0010b30111dbfb8e523634e7b63328992106 (diff)
XPath: Always allocate xpath_strings on temporary stack for concat
The static_buffer optimization seems to come from the time where the on-heap buffer was allocated using global memory operations. At this point the temporary buffer and temporary string storage all come from the evaluation stack (that can be partially allocated on heap...), so the extra logic isn't relevant for performance.
-rw-r--r--src/pugixml.cpp13
1 files changed, 3 insertions, 10 deletions
diff --git a/src/pugixml.cpp b/src/pugixml.cpp
index 01ab41d..071649b 100644
--- a/src/pugixml.cpp
+++ b/src/pugixml.cpp
@@ -10442,16 +10442,9 @@ PUGI__NS_BEGIN
size_t count = 1;
for (xpath_ast_node* nc = _right; nc; nc = nc->_next) count++;
- // gather all strings
- xpath_string static_buffer[4];
- xpath_string* buffer = static_buffer;
-
- // allocate on-heap for large concats
- if (count > sizeof(static_buffer) / sizeof(static_buffer[0]))
- {
- buffer = static_cast<xpath_string*>(stack.temp->allocate(count * sizeof(xpath_string)));
- if (!buffer) return xpath_string();
- }
+ // allocate a buffer for temporary string objects
+ xpath_string* buffer = static_cast<xpath_string*>(stack.temp->allocate(count * sizeof(xpath_string)));
+ if (!buffer) return xpath_string();
// evaluate all strings to temporary stack
xpath_stack swapped_stack = {stack.temp, stack.result};