From bd5d3936ec77e0ec42d6f9d99d377d807e9892f8 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Fri, 9 Jun 2017 15:54:26 -0700 Subject: 3903 - minimal render when pressing 'tab' Turns out all I had to do was reset `go-render?` to false. --- html/060rewrite_literal_string.cc.html | 86 +++++++++++++++++----------------- 1 file changed, 44 insertions(+), 42 deletions(-) (limited to 'html/060rewrite_literal_string.cc.html') diff --git a/html/060rewrite_literal_string.cc.html b/html/060rewrite_literal_string.cc.html index 7689488e..0b913764 100644 --- a/html/060rewrite_literal_string.cc.html +++ b/html/060rewrite_literal_string.cc.html @@ -75,7 +75,7 @@ if ('onhashchange' in window) { 13 14 :(before "End Instruction Inserting/Deleting Transforms") 15 initialize_transform_rewrite_literal_string_to_text(); -16 Transform.push_back(rewrite_literal_string_to_text); // idempotent +16 Transform.push_back(rewrite_literal_string_to_text); // idempotent 17 18 :(before "End Globals") 19 set<string> recipes_taking_literal_strings; @@ -92,47 +92,49 @@ if ('onhashchange' in window) { 30 recipes_taking_literal_strings.insert("trace-should-contain"); 31 recipes_taking_literal_strings.insert("trace-should-not-contain"); 32 recipes_taking_literal_strings.insert("check-trace-count-for-label"); -33 // End initialize_transform_rewrite_literal_string_to_text() -34 } -35 -36 void rewrite_literal_string_to_text(const recipe_ordinal r) { -37 recipe& caller = get(Recipe, r); -38 trace(9991, "transform") << "--- rewrite literal strings in recipe " << caller.name << end(); -39 if (contains_numeric_locations(caller)) return; -40 vector<instruction> new_instructions; -41 for (int i = 0; i < SIZE(caller.steps); ++i) { -42 ¦ instruction& inst = caller.steps.at(i); -43 ¦ if (recipes_taking_literal_strings.find(inst.name) == recipes_taking_literal_strings.end()) { -44 ¦ ¦ for (int j = 0; j < SIZE(inst.ingredients); ++j) { -45 ¦ ¦ ¦ if (!is_literal_text(inst.ingredients.at(j))) continue; -46 ¦ ¦ ¦ instruction def; -47 ¦ ¦ ¦ ostringstream ingredient_name; -48 ¦ ¦ ¦ ingredient_name << inst.name << '_' << i << '_' << j << ":text"; -49 ¦ ¦ ¦ def.name = "new"; -50 ¦ ¦ ¦ def.ingredients.push_back(inst.ingredients.at(j)); -51 ¦ ¦ ¦ def.products.push_back(reagent(ingredient_name.str())); -52 ¦ ¦ ¦ new_instructions.push_back(def); -53 ¦ ¦ ¦ inst.ingredients.at(j).clear(); // reclaim old memory -54 ¦ ¦ ¦ inst.ingredients.at(j) = reagent(ingredient_name.str()); -55 ¦ ¦ } -56 ¦ } -57 ¦ new_instructions.push_back(inst); -58 } -59 caller.steps.swap(new_instructions); -60 } -61 -62 bool contains_numeric_locations(const recipe& caller) { -63 for (int i = 0; i < SIZE(caller.steps); ++i) { -64 ¦ const instruction& inst = caller.steps.at(i); -65 ¦ for (int in = 0; in < SIZE(inst.ingredients); ++in) -66 ¦ ¦ if (is_numeric_location(inst.ingredients.at(in))) -67 ¦ ¦ ¦ return true; -68 ¦ for (int out = 0; out < SIZE(inst.products); ++out) -69 ¦ ¦ if (is_numeric_location(inst.products.at(out))) -70 ¦ ¦ ¦ return true; -71 } -72 return false; -73 } +33 recipes_taking_literal_strings.insert("check-trace-count-for-label-greater-than"); +34 recipes_taking_literal_strings.insert("check-trace-count-for-label-lesser-than"); +35 // End initialize_transform_rewrite_literal_string_to_text() +36 } +37 +38 void rewrite_literal_string_to_text(const recipe_ordinal r) { +39 recipe& caller = get(Recipe, r); +40 trace(9991, "transform") << "--- rewrite literal strings in recipe " << caller.name << end(); +41 if (contains_numeric_locations(caller)) return; +42 vector<instruction> new_instructions; +43 for (int i = 0; i < SIZE(caller.steps); ++i) { +44 ¦ instruction& inst = caller.steps.at(i); +45 ¦ if (recipes_taking_literal_strings.find(inst.name) == recipes_taking_literal_strings.end()) { +46 ¦ ¦ for (int j = 0; j < SIZE(inst.ingredients); ++j) { +47 ¦ ¦ ¦ if (!is_literal_text(inst.ingredients.at(j))) continue; +48 ¦ ¦ ¦ instruction def; +49 ¦ ¦ ¦ ostringstream ingredient_name; +50 ¦ ¦ ¦ ingredient_name << inst.name << '_' << i << '_' << j << ":text"; +51 ¦ ¦ ¦ def.name = "new"; +52 ¦ ¦ ¦ def.ingredients.push_back(inst.ingredients.at(j)); +53 ¦ ¦ ¦ def.products.push_back(reagent(ingredient_name.str())); +54 ¦ ¦ ¦ new_instructions.push_back(def); +55 ¦ ¦ ¦ inst.ingredients.at(j).clear(); // reclaim old memory +56 ¦ ¦ ¦ inst.ingredients.at(j) = reagent(ingredient_name.str()); +57 ¦ ¦ } +58 ¦ } +59 ¦ new_instructions.push_back(inst); +60 } +61 caller.steps.swap(new_instructions); +62 } +63 +64 bool contains_numeric_locations(const recipe& caller) { +65 for (int i = 0; i < SIZE(caller.steps); ++i) { +66 ¦ const instruction& inst = caller.steps.at(i); +67 ¦ for (int in = 0; in < SIZE(inst.ingredients); ++in) +68 ¦ ¦ if (is_numeric_location(inst.ingredients.at(in))) +69 ¦ ¦ ¦ return true; +70 ¦ for (int out = 0; out < SIZE(inst.products); ++out) +71 ¦ ¦ if (is_numeric_location(inst.products.at(out))) +72 ¦ ¦ ¦ return true; +73 } +74 return false; +75 } -- cgit 1.4.1-2-gfad0