diff options
author | John Wiegley <johnw@newartisans.com> | 2007-04-23 04:42:28 +0000 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2008-04-13 03:38:30 -0400 |
commit | be9f18ccfe81acdd2f34b27352f2843235fab69b (patch) | |
tree | 89bb8aea8ac4d367b1c054eeea5d3fd9f7bb197c /xpath.cc | |
parent | ece13a8cf10e9afb576139411f450d8b37ec8e65 (diff) | |
download | fork-ledger-be9f18ccfe81acdd2f34b27352f2843235fab69b.tar.gz fork-ledger-be9f18ccfe81acdd2f34b27352f2843235fab69b.tar.bz2 fork-ledger-be9f18ccfe81acdd2f34b27352f2843235fab69b.zip |
Reduced memory consumption of register report.
Diffstat (limited to 'xpath.cc')
-rw-r--r-- | xpath.cc | 12 |
1 files changed, 9 insertions, 3 deletions
@@ -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<value_t::sequence_t> nodes(new value_t::sequence_t); if (ptr->flags & XML_NODE_IS_PARENT) { parent_node_t * parent = static_cast<parent_node_t *>(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); |