diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2015-11-06 11:06:58 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2015-11-06 11:17:25 -0800 |
commit | 795f5244abc9b9f26ff621fd1997db427289d2ba (patch) | |
tree | 7018937b9d11ad07dab840789c444ca82ba22333 /011load.cc | |
parent | 90e9eb3d4fa431ed0e7864caead19cd2e06b2c65 (diff) | |
download | mu-795f5244abc9b9f26ff621fd1997db427289d2ba.tar.gz |
2377 - stop using operator[] in map
I'm still seeing all sorts of failures in turning on layer 11 of edit/, so I'm backing away and nailing down every culprit I run into. First up: stop accidentally inserting empty objects into maps during lookups. Commands run: $ sed -i 's/\(Recipe_ordinal\|Recipe\|Type_ordinal\|Type\|Memory\)\[\([^]]*\)\] = \(.*\);/put(\1, \2, \3);/' 0[1-9]* $ vi 075scenario_console.cc # manually fix up Memory[Memory[CONSOLE]] $ sed -i 's/\(Memory\)\[\([^]]*\)\]/get_or_insert(\1, \2)/' 0[1-9]* $ sed -i 's/\(Recipe_ordinal\|Type_ordinal\)\[\([^]]*\)\]/get(\1, \2)/' 0[1-9]* $ sed -i 's/\(Recipe\|Type\)\[\([^]]*\)\]/get(\1, \2)/' 0[1-9]* Now mu dies pretty quickly because of all the places I try to lookup a missing value.
Diffstat (limited to '011load.cc')
-rw-r--r-- | 011load.cc | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/011load.cc b/011load.cc index 10fe3817..d7150335 100644 --- a/011load.cc +++ b/011load.cc @@ -48,20 +48,20 @@ long long int slurp_recipe(istream& in) { raise_error << "empty result.name\n" << end(); trace(9991, "parse") << "--- defining " << result.name << end(); if (Recipe_ordinal.find(result.name) == Recipe_ordinal.end()) { - Recipe_ordinal[result.name] = Next_recipe_ordinal++; + put(Recipe_ordinal, result.name, Next_recipe_ordinal++); } - if (Recipe.find(Recipe_ordinal[result.name]) != Recipe.end()) { + if (Recipe.find(get(Recipe_ordinal, result.name)) != Recipe.end()) { trace(9991, "parse") << "already exists" << end(); if (warn_on_redefine(result.name)) raise << "redefining recipe " << result.name << "\n" << end(); - Recipe.erase(Recipe_ordinal[result.name]); + Recipe.erase(get(Recipe_ordinal, result.name)); } slurp_body(in, result); // End recipe Body(result) - Recipe[Recipe_ordinal[result.name]] = result; + get(Recipe, get(Recipe_ordinal, result.name)) = result; // track added recipes because we may need to undo them in tests; see below - recently_added_recipes.push_back(Recipe_ordinal[result.name]); - return Recipe_ordinal[result.name]; + recently_added_recipes.push_back(get(Recipe_ordinal, result.name)); + return get(Recipe_ordinal, result.name); } void slurp_body(istream& in, recipe& result) { @@ -243,7 +243,7 @@ long long int Reserved_for_tests = 1000; :(before "End Setup") for (long long int i = 0; i < SIZE(recently_added_recipes); ++i) { if (recently_added_recipes.at(i) >= Reserved_for_tests) // don't renumber existing recipes, like 'interactive' - Recipe_ordinal.erase(Recipe[recently_added_recipes.at(i)].name); + Recipe_ordinal.erase(get(Recipe, recently_added_recipes.at(i)).name); Recipe.erase(recently_added_recipes.at(i)); } // Clear Other State For recently_added_recipes |