XPath stack optimization: Reduce stack usage during parsing by sharing scratch buffer for variable/number parsing (we only need one per parser)
git-svn-id: http://pugixml.googlecode.com/svn/trunk@928 99668b35-9821-0410-8761-19e4c4f06640
This commit is contained in:
parent
971fd96764
commit
ed30b95a42
@ -6440,10 +6440,8 @@ PUGI__NS_BEGIN
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
PUGI__FN bool convert_string_to_number(const char_t* begin, const char_t* end, double* out_result)
|
PUGI__FN bool convert_string_to_number(char_t (&buffer)[32], const char_t* begin, const char_t* end, double* out_result)
|
||||||
{
|
{
|
||||||
char_t buffer[32];
|
|
||||||
|
|
||||||
size_t length = static_cast<size_t>(end - begin);
|
size_t length = static_cast<size_t>(end - begin);
|
||||||
char_t* scratch = buffer;
|
char_t* scratch = buffer;
|
||||||
|
|
||||||
@ -6736,10 +6734,8 @@ PUGI__NS_BEGIN
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PUGI__FN xpath_variable* get_variable(xpath_variable_set* set, const char_t* begin, const char_t* end)
|
PUGI__FN xpath_variable* get_variable(char_t (&buffer)[32], xpath_variable_set* set, const char_t* begin, const char_t* end)
|
||||||
{
|
{
|
||||||
char_t buffer[32];
|
|
||||||
|
|
||||||
size_t length = static_cast<size_t>(end - begin);
|
size_t length = static_cast<size_t>(end - begin);
|
||||||
char_t* scratch = buffer;
|
char_t* scratch = buffer;
|
||||||
|
|
||||||
@ -8730,6 +8726,8 @@ PUGI__NS_BEGIN
|
|||||||
|
|
||||||
xpath_parse_result* _result;
|
xpath_parse_result* _result;
|
||||||
|
|
||||||
|
char_t _scratch[32];
|
||||||
|
|
||||||
#ifdef PUGIXML_NO_EXCEPTIONS
|
#ifdef PUGIXML_NO_EXCEPTIONS
|
||||||
jmp_buf _error_handler;
|
jmp_buf _error_handler;
|
||||||
#endif
|
#endif
|
||||||
@ -9018,7 +9016,7 @@ PUGI__NS_BEGIN
|
|||||||
if (!_variables)
|
if (!_variables)
|
||||||
throw_error("Unknown variable: variable set is not provided");
|
throw_error("Unknown variable: variable set is not provided");
|
||||||
|
|
||||||
xpath_variable* var = get_variable(_variables, name.begin, name.end);
|
xpath_variable* var = get_variable(_scratch, _variables, name.begin, name.end);
|
||||||
|
|
||||||
if (!var)
|
if (!var)
|
||||||
throw_error("Unknown variable: variable set does not contain the given name");
|
throw_error("Unknown variable: variable set does not contain the given name");
|
||||||
@ -9056,7 +9054,7 @@ PUGI__NS_BEGIN
|
|||||||
{
|
{
|
||||||
double value = 0;
|
double value = 0;
|
||||||
|
|
||||||
if (!convert_string_to_number(_lexer.contents().begin, _lexer.contents().end, &value))
|
if (!convert_string_to_number(_scratch, _lexer.contents().begin, _lexer.contents().end, &value))
|
||||||
throw_error_oom();
|
throw_error_oom();
|
||||||
|
|
||||||
xpath_ast_node* n = new (alloc_node()) xpath_ast_node(ast_number_constant, xpath_type_number, value);
|
xpath_ast_node* n = new (alloc_node()) xpath_ast_node(ast_number_constant, xpath_type_number, value);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user