summaryrefslogtreecommitdiff
path: root/xpath.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2007-04-23 04:42:28 +0000
committerJohn Wiegley <johnw@newartisans.com>2008-04-13 03:38:30 -0400
commitbe9f18ccfe81acdd2f34b27352f2843235fab69b (patch)
tree89bb8aea8ac4d367b1c054eeea5d3fd9f7bb197c /xpath.cc
parentece13a8cf10e9afb576139411f450d8b37ec8e65 (diff)
downloadfork-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.cc12
1 files changed, 9 insertions, 3 deletions
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<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);