From be9f18ccfe81acdd2f34b27352f2843235fab69b Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Mon, 23 Apr 2007 04:42:28 +0000 Subject: Reduced memory consumption of register report. --- xpath.cc | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'xpath.cc') diff --git a/xpath.cc b/xpath.cc index aa62edd9..e77f7bc7 100644 --- a/xpath.cc +++ b/xpath.cc @@ -655,10 +655,16 @@ xpath_t::parse_value_term(std::istream& in, unsigned short tflags) const #endif string ident = tok.value.to_string(); + int id = -1; if (std::isdigit(ident[0])) { node.reset(new op_t(op_t::ARG_INDEX)); node->arg_index = std::atol(ident.c_str()); - } else { + } + else if ((id = document_t::lookup_builtin_id(ident)) != -1) { + node.reset(new op_t(op_t::NODE_ID)); + node->name_id = id; + } + else { node.reset(new op_t(op_t::NODE_NAME)); node->name = new string(ident); } @@ -1312,7 +1318,7 @@ xpath_t::op_t * xpath_t::op_t::compile(value_t * context, scope_t * scope, // First, look up the symbol as a node name within the current // context. If any exist, then return the set of names. - value_t::sequence_t * nodes = new value_t::sequence_t; + std::auto_ptr nodes(new value_t::sequence_t); if (ptr->flags & XML_NODE_IS_PARENT) { parent_node_t * parent = static_cast(ptr); @@ -1325,7 +1331,7 @@ xpath_t::op_t * xpath_t::op_t::compile(value_t * context, scope_t * scope, nodes->push_back(node); } } - return wrap_value(nodes)->acquire(); + return wrap_value(nodes.release())->acquire(); } else { assert(ptr); int id = ptr->document->lookup_name_id(*name); -- cgit v1.2.3