From 344c74a74c350f755d916ef6e6ac4b75160dcf86 Mon Sep 17 00:00:00 2001 From: Arseny Kapoulkine Date: Mon, 13 Nov 2017 19:10:36 -0800 Subject: 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. --- src/pugixml.cpp | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) (limited to 'src') 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(stack.temp->allocate(count * sizeof(xpath_string))); - if (!buffer) return xpath_string(); - } + // allocate a buffer for temporary string objects + xpath_string* buffer = static_cast(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}; -- cgit v1.2.3