summaryrefslogtreecommitdiff
path: root/src/cnode/cnode.cpp
diff options
context:
space:
mode:
authorAn-Cheng Huang <ancheng@vyatta.com>2011-03-17 11:48:54 -0700
committerAn-Cheng Huang <ancheng@vyatta.com>2011-03-17 11:48:54 -0700
commiteb9f5718d412022015bb65eb08c30785c79e79e6 (patch)
treebe0b6a9de27965e39c44c5c8a88adf9caa13abf8 /src/cnode/cnode.cpp
parentcda3f423c311fd30e8cc24e2de67d99baf352b2a (diff)
downloadvyatta-cfg-eb9f5718d412022015bb65eb08c30785c79e79e6.tar.gz
vyatta-cfg-eb9f5718d412022015bb65eb08c30785c79e79e6.zip
add config path abstraction and high-level caching
* part of the config backend cleanup/optimization work. * improves the performance of "load" (w/o commit) by ~55% and "show" by ~15%.
Diffstat (limited to 'src/cnode/cnode.cpp')
-rw-r--r--src/cnode/cnode.cpp25
1 files changed, 12 insertions, 13 deletions
diff --git a/src/cnode/cnode.cpp b/src/cnode/cnode.cpp
index f484fb1..cd4f6cf 100644
--- a/src/cnode/cnode.cpp
+++ b/src/cnode/cnode.cpp
@@ -28,20 +28,19 @@ using namespace cnode;
////// constructors/destructors
-CfgNode::CfgNode(vector<string>& path_comps, char *name, char *val,
- char *comment, int deact, Cstore *cstore,
- bool tag_if_invalid)
+CfgNode::CfgNode(Cpath& path_comps, char *name, char *val, char *comment,
+ int deact, Cstore *cstore, bool tag_if_invalid)
: _is_tag(false), _is_leaf(false), _is_multi(false), _is_value(false),
_is_default(false), _is_deactivated(false), _is_leaf_typeless(false),
_is_invalid(false), _is_empty(true), _exists(true)
{
if (name && name[0]) {
// name must be non-empty
- path_comps.push_back(name);
+ path_comps.push(name);
}
if (val) {
// value could be empty
- path_comps.push_back(val);
+ path_comps.push(val);
}
while (1) {
@@ -50,7 +49,7 @@ CfgNode::CfgNode(vector<string>& path_comps, char *name, char *val,
break;
}
- auto_ptr<Ctemplate> def(cstore->parseTmpl(path_comps, false));
+ tr1::shared_ptr<Ctemplate> def(cstore->parseTmpl(path_comps, false));
if (def.get()) {
// got the def
_is_tag = def->isTag();
@@ -106,16 +105,16 @@ CfgNode::CfgNode(vector<string>& path_comps, char *name, char *val,
} else {
_value = val;
}
- path_comps.pop_back();
+ path_comps.pop();
}
if (name && name[0]) {
_name = name;
- path_comps.pop_back();
+ path_comps.pop();
}
}
-CfgNode::CfgNode(Cstore& cstore, vector<string>& path_comps,
- bool active, bool recursive)
+CfgNode::CfgNode(Cstore& cstore, Cpath& path_comps, bool active,
+ bool recursive)
: _is_tag(false), _is_leaf(false), _is_multi(false), _is_value(false),
_is_default(false), _is_deactivated(false), _is_leaf_typeless(false),
_is_invalid(false), _is_empty(false), _exists(true)
@@ -124,7 +123,7 @@ CfgNode::CfgNode(Cstore& cstore, vector<string>& path_comps,
* "root", treat it as an intermediate node.
*/
if (path_comps.size() > 0) {
- auto_ptr<Ctemplate> def(cstore.parseTmpl(path_comps, false));
+ tr1::shared_ptr<Ctemplate> def(cstore.parseTmpl(path_comps, false));
if (def.get()) {
// got the def
if (!cstore.cfgPathExists(path_comps, active)) {
@@ -202,10 +201,10 @@ CfgNode::CfgNode(Cstore& cstore, vector<string>& path_comps,
// recurse
for (size_t i = 0; i < cnodes.size(); i++) {
- path_comps.push_back(cnodes[i]);
+ path_comps.push(cnodes[i]);
CfgNode *cn = new CfgNode(cstore, path_comps, active, recursive);
_child_nodes.push_back(cn);
- path_comps.pop_back();
+ path_comps.pop();
}
}