diff options
author | Kartik Agaram <vc@akkartik.com> | 2018-08-03 23:08:09 -0700 |
---|---|---|
committer | Kartik Agaram <vc@akkartik.com> | 2018-08-03 23:08:09 -0700 |
commit | 85173b622021de062706df81947df7ae2300b654 (patch) | |
tree | 8800d1739d9f357471dc072ff40ba38e107d48cb | |
parent | 4e38301e910115a4f782b5a461a4830966d784ba (diff) | |
download | mu-85173b622021de062706df81947df7ae2300b654.tar.gz |
4466
Why the heck was I using ints for OPEN/CLOSED in the first place?!
-rw-r--r-- | 040brace.cc | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/040brace.cc b/040brace.cc index 2501bc1b..b3006456 100644 --- a/040brace.cc +++ b/040brace.cc @@ -36,19 +36,19 @@ Transform.push_back(transform_braces); // idempotent :(code) void transform_braces(const recipe_ordinal r) { - const int OPEN = 0, CLOSE = 1; + const bool OPEN = false, CLOSE = true; // use signed integer for step index because we'll be doing arithmetic on it - list<pair<int/*OPEN/CLOSE*/, /*step*/int> > braces; + list<pair<bool/*OPEN/CLOSE*/, /*step*/int> > braces; trace(9991, "transform") << "--- transform braces for recipe " << get(Recipe, r).name << end(); for (int index = 0; index < SIZE(get(Recipe, r).steps); ++index) { const instruction& inst = get(Recipe, r).steps.at(index); if (inst.label == "{") { trace(9993, "transform") << maybe(get(Recipe, r).name) << "push (open, " << index << ")" << end(); - braces.push_back(pair<int,int>(OPEN, index)); + braces.push_back(pair<bool,int>(OPEN, index)); } if (inst.label == "}") { trace(9993, "transform") << "push (close, " << index << ")" << end(); - braces.push_back(pair<int,int>(CLOSE, index)); + braces.push_back(pair<bool,int>(CLOSE, index)); } } stack</*step*/int> open_braces; @@ -132,9 +132,9 @@ void transform_braces(const recipe_ordinal r) { // returns a signed integer not just so that we can return -1 but also to // enable future signed arithmetic -int matching_brace(int index, const list<pair<int, int> >& braces, recipe_ordinal r) { +int matching_brace(int index, const list<pair<bool, int> >& braces, recipe_ordinal r) { int stacksize = 0; - for (list<pair<int, int> >::const_iterator p = braces.begin(); p != braces.end(); ++p) { + for (list<pair<bool, int> >::const_iterator p = braces.begin(); p != braces.end(); ++p) { if (p->second < index) continue; stacksize += (p->first ? 1 : -1); if (stacksize == 0) return p->second; |