From e567fa20338e408ff7733332680d12cb82d12bec Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Sun, 18 Jul 2021 12:18:11 +0200 Subject: [PATCH] IF_KEY_EXISTS used in util.cpp --- util.cpp | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/util.cpp b/util.cpp index a2aff099..f98e7d60 100644 --- a/util.cpp +++ b/util.cpp @@ -207,11 +207,10 @@ cld exp_parser::parse(int prio) { cld c = rparse(0); force_eat(")"); - if(extra_params.count("angleunit")) { - - a *= extra_params["angleunit"]; - b *= extra_params["angleunit"]; - c *= extra_params["angleunit"]; + IF_KEY_EXISTS(it, extra_params, "angleunit") { + a *= it->second; + b *= it->second; + c *= it->second; } return edge_of_triangle_with_angles(real(a), real(b), real(c)); @@ -238,14 +237,14 @@ cld exp_parser::parse(int prio) { test.compute_sum(); test.compute_geometry(); res = test.edgelength; - if(extra_params.count("distunit")) - res /= extra_params["distunit"]; + IF_KEY_EXISTS(it, extra_params, "distunit") + res /= it->second; } #endif else if(eat("regangle(")) { cld edgelen = parse(0); - if(extra_params.count("distunit")) { - edgelen = edgelen * extra_params["distunit"]; + IF_KEY_EXISTS(it, extra_params, "distunit") { + edgelen = edgelen * it->second; } force_eat(","); @@ -261,14 +260,14 @@ cld exp_parser::parse(int prio) { if(arb::legacy) { res = M_PI - result; - if(extra_params.count("angleofs")) - res -= extra_params["angleofs"]; + IF_KEY_EXISTS(it, extra_params, "angleofs") + res -= it->second; } else res = result; - if(extra_params.count("angleunit")) - res /= extra_params["angleunit"]; + IF_KEY_EXISTS(it, extra_params, "angleunit") + res /= it->second; } else if(eat("test(")) { res = parsepar(); @@ -319,8 +318,8 @@ cld exp_parser::parse(int prio) { else if(next() == '(') at++, res = parsepar(); else { string number = next_token(); - if(extra_params.count(number)) res = extra_params[number]; - else if(params.count(number)) res = params[number]->get_cld(); + IF_KEY_EXISTS(it, extra_params, number) res = it->second; + else IF_KEY_EXISTS(it, params, number) res = it->second->get_cld(); else if(number == "e") res = exp(1); else if(number == "i") res = cld(0, 1); else if(number == "p" || number == "pi") res = M_PI;