summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAn-Cheng Huang <ancheng@vyatta.com>2011-03-01 16:55:34 -0800
committerAn-Cheng Huang <ancheng@vyatta.com>2011-03-01 16:55:34 -0800
commit0acc2454cacb3ccab512b41b96cbaa024ebb0117 (patch)
tree9c84c96681fd13c2ffd96eb92da09884058c3fa0
parentcf5c5f6a492bb92b25aeb880e46e9df2560a4c2e (diff)
downloadvyatta-cfg-0acc2454cacb3ccab512b41b96cbaa024ebb0117.tar.gz
vyatta-cfg-0acc2454cacb3ccab512b41b96cbaa024ebb0117.zip
tweak map iterator usage
-rw-r--r--src/cnode/cnode-algorithm.cpp10
-rw-r--r--src/cparse/cparse.ypp5
-rw-r--r--src/cstore/cstore.cpp6
-rw-r--r--src/cstore/unionfs/cstore-unionfs.cpp8
-rw-r--r--src/cstore/unionfs/cstore-unionfs.hpp2
5 files changed, 18 insertions, 13 deletions
diff --git a/src/cnode/cnode-algorithm.cpp b/src/cnode/cnode-algorithm.cpp
index 9ac5404..9256e7c 100644
--- a/src/cnode/cnode-algorithm.cpp
+++ b/src/cnode/cnode-algorithm.cpp
@@ -143,10 +143,12 @@ _cmp_non_leaf_nodes(const CfgNode *cfg1, const CfgNode *cfg2,
Cstore::sortNodes(cnodes);
for (size_t i = 0; i < cnodes.size(); i++) {
- bool in1 = (nmap1.find(cnodes[i]) != nmap1.end());
- bool in2 = (nmap2.find(cnodes[i]) != nmap2.end());
- CfgNode *c1 = (in1 ? nmap1[cnodes[i]] : NULL);
- CfgNode *c2 = (in2 ? nmap2[cnodes[i]] : NULL);
+ Cstore::MapT<string, CfgNode *>::iterator p1 = nmap1.find(cnodes[i]);
+ Cstore::MapT<string, CfgNode *>::iterator p2 = nmap2.find(cnodes[i]);
+ bool in1 = (p1 != nmap1.end());
+ bool in2 = (p2 != nmap2.end());
+ CfgNode *c1 = (in1 ? p1->second : NULL);
+ CfgNode *c2 = (in2 ? p2->second : NULL);
rcnodes1.push_back(c1);
rcnodes2.push_back(c2);
}
diff --git a/src/cparse/cparse.ypp b/src/cparse/cparse.ypp
index 6ce60d0..24abbad 100644
--- a/src/cparse/cparse.ypp
+++ b/src/cparse/cparse.ypp
@@ -53,8 +53,9 @@ add_node()
{
pcomps.push_back(nname);
CfgNode *onode = NULL;
- if (node_map.find(pcomps) != node_map.end()) {
- onode = node_map[pcomps];
+ map<vector<string>, CfgNode *>::iterator it = node_map.find(pcomps);
+ if (it != node_map.end()) {
+ onode = it->second;
}
pcomps.pop_back();
if (onode) {
diff --git a/src/cstore/cstore.cpp b/src/cstore/cstore.cpp
index f32e6ec..91d82e3 100644
--- a/src/cstore/cstore.cpp
+++ b/src/cstore/cstore.cpp
@@ -1980,10 +1980,12 @@ Cstore::sort_func_deb_version(string a, string b)
void
Cstore::sort_nodes(vector<string>& nvec, unsigned int sort_alg)
{
- if (_sort_func_map.find(sort_alg) == _sort_func_map.end()) {
+ Cstore::MapT<unsigned int, Cstore::SortFuncT>::iterator p
+ = _sort_func_map.find(sort_alg);
+ if (p == _sort_func_map.end()) {
return;
}
- sort(nvec.begin(), nvec.end(), _sort_func_map[sort_alg]);
+ sort(nvec.begin(), nvec.end(), p->second);
}
/* try to append the logical path to template path.
diff --git a/src/cstore/unionfs/cstore-unionfs.cpp b/src/cstore/unionfs/cstore-unionfs.cpp
index 50aefb5..af4075c 100644
--- a/src/cstore/unionfs/cstore-unionfs.cpp
+++ b/src/cstore/unionfs/cstore-unionfs.cpp
@@ -82,7 +82,7 @@ _escape_char(char c)
{
Cstore::MapT<char, string>::iterator p = _fs_escape_chars.find(c);
if (p != _fs_escape_chars.end()) {
- return _fs_escape_chars[c];
+ return p->second;
} else {
return string(1, c);
}
@@ -97,7 +97,7 @@ _escape_path_name(const string& path)
= _escape_path_name_cache.find(path);
if (p != _escape_path_name_cache.end()) {
// found escaped string in cache. just return it.
- return _escape_path_name_cache[path];
+ return p->second;
}
// special case for empty string
@@ -120,7 +120,7 @@ _unescape_path_name(const string& path)
= _unescape_path_name_cache.find(path);
if (p != _unescape_path_name_cache.end()) {
// found unescaped string in cache. just return it.
- return _unescape_path_name_cache[path];
+ return p->second;
}
// assume all escape patterns are 3-char
@@ -133,7 +133,7 @@ _unescape_path_name(const string& path)
string s = path.substr(i, 3);
Cstore::MapT<string, char>::iterator p = _fs_unescape_chars.find(s);
if (p != _fs_unescape_chars.end()) {
- char c = _fs_unescape_chars[s];
+ char c = p->second;
if (path.size() == 3 && c == -1) {
// special case for empty string
npath = "";
diff --git a/src/cstore/unionfs/cstore-unionfs.hpp b/src/cstore/unionfs/cstore-unionfs.hpp
index 82bda2a..47bfe26 100644
--- a/src/cstore/unionfs/cstore-unionfs.hpp
+++ b/src/cstore/unionfs/cstore-unionfs.hpp
@@ -136,7 +136,7 @@ private:
if (it == saved_paths.end()) {
exit_internal("restore_paths: handle not found\n");
}
- pair<b_fs::path, b_fs::path> p = saved_paths[handle];
+ pair<b_fs::path, b_fs::path> p = it->second;
mutable_cfg_path = p.first;
tmpl_path = p.second;
};