From 795f5244abc9b9f26ff621fd1997db427289d2ba Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Fri, 6 Nov 2015 11:06:58 -0800 Subject: 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. --- 052tangle.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to '052tangle.cc') diff --git a/052tangle.cc b/052tangle.cc index 0582f79f..c3bc7e46 100644 --- a/052tangle.cc +++ b/052tangle.cc @@ -73,8 +73,8 @@ void insert_fragments(const recipe_ordinal r) { made_progress = false; // create a new vector because insertions invalidate iterators vector result; - for (long long int i = 0; i < SIZE(Recipe[r].steps); ++i) { - const instruction& inst = Recipe[r].steps.at(i); + for (long long int i = 0; i < SIZE(get(Recipe, r).steps); ++i) { + const instruction& inst = get(Recipe, r).steps.at(i); if (!inst.is_label || !is_waypoint(inst.label) || inst.tangle_done) { result.push_back(inst); continue; @@ -83,7 +83,7 @@ void insert_fragments(const recipe_ordinal r) { made_progress = true; Fragments_used.insert(inst.label); ostringstream prefix; - prefix << '+' << Recipe[r].name << '_' << pass << '_' << i; + prefix << '+' << get(Recipe, r).name << '_' << pass << '_' << i; if (Before_fragments.find(inst.label) != Before_fragments.end()) { append_fragment(result, Before_fragments[inst.label].steps, prefix.str()); } @@ -92,7 +92,7 @@ void insert_fragments(const recipe_ordinal r) { append_fragment(result, After_fragments[inst.label].steps, prefix.str()); } } - Recipe[r].steps.swap(result); + get(Recipe, r).steps.swap(result); ++pass; } } -- cgit 1.4.1-2-gfad0