about summary refs log tree commit diff stats
path: root/046closure_name.cc
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-11-06 13:22:16 -0800
committerKartik K. Agaram <vc@akkartik.com>2015-11-06 13:22:30 -0800
commitf3760b0f2828250b4b5fb1a52601fe6b11ff328f (patch)
tree69ec57c652ff823e92146281ba656e3eaba57eb7 /046closure_name.cc
parent12f304a333ecee6326a8111e0d8e1c494ee92087 (diff)
downloadmu-f3760b0f2828250b4b5fb1a52601fe6b11ff328f.tar.gz
2379 - further improvements to map operations
Commands run:

  $ sed -i 's/\([^. (]*\)\.find(\([^)]*\)) != [^.]*\.end()/contains_key(\1, \2)/g' 0[^0]*cc
  $ sed -i 's/\([^. (]*\)\.find(\([^)]*\)) == [^.]*\.end()/!contains_key(\1, \2)/g' 0[^0]*cc
Diffstat (limited to '046closure_name.cc')
-rw-r--r--046closure_name.cc8
1 files changed, 4 insertions, 4 deletions
diff --git a/046closure_name.cc b/046closure_name.cc
index 70c3481e..3d8e2e00 100644
--- a/046closure_name.cc
+++ b/046closure_name.cc
@@ -65,7 +65,7 @@ void collect_surrounding_spaces(const recipe_ordinal r) {
       }
       if (s->right) raise_error << "slot 0 should have a single value in /names, but got " << inst.products.at(j).to_string() << '\n' << end();
       const string& surrounding_recipe_name = s->value;
-      if (Surrounding_space.find(r) != Surrounding_space.end()
+      if (contains_key(Surrounding_space, r)
           && Surrounding_space[r] != get(Recipe_ordinal, surrounding_recipe_name)) {
         raise_error << "recipe " << get(Recipe, r).name << " can have only one 'surrounding' recipe but has " << Recipe[Surrounding_space[r]].name << " and " << surrounding_recipe_name << '\n' << end();
         continue;
@@ -99,7 +99,7 @@ long long int lookup_name(const reagent& x, const recipe_ordinal default_recipe)
 // recursively call transform_names on it.
 long long int lookup_name(const reagent& x, const recipe_ordinal r, set<recipe_ordinal>& done, vector<recipe_ordinal>& path) {
   if (!Name[r].empty()) return Name[r][x.name];
-  if (done.find(r) != done.end()) {
+  if (contains_key(done, r)) {
     raise_error << "can't compute address of " << x.to_string() << " because " << end();
     for (long long int i = 1; i < SIZE(path); ++i) {
       raise_error << path.at(i-1) << " requires computing names of " << path.at(i) << '\n' << end();
@@ -116,7 +116,7 @@ long long int lookup_name(const reagent& x, const recipe_ordinal r, set<recipe_o
 
 recipe_ordinal lookup_surrounding_recipe(const recipe_ordinal r, long long int n) {
   if (n == 0) return r;
-  if (Surrounding_space.find(r) == Surrounding_space.end()) {
+  if (!contains_key(Surrounding_space, r)) {
     raise_error << "don't know surrounding recipe of " << get(Recipe, r).name << '\n' << end();
     return 0;
   }
@@ -135,5 +135,5 @@ bool already_transformed(const reagent& r, const map<string, long long int>& nam
     }
     if (p->value != "0") return true;
   }
-  return names.find(r.name) != names.end();
+  return contains_key(names, r.name);
 }