Huge performance improvement: passing variables as pointers avoiding copies

This commit is contained in:
Felipe Zimmerle
2015-09-18 20:21:12 -03:00
parent 2451bf05d7
commit 076a02951c
45 changed files with 207 additions and 208 deletions

View File

@@ -116,30 +116,29 @@ bool SetVar::evaluate(Rule *rule, Assay *assay) {
value = 0;
}
int pre = 0;
try {
pre = stoi(predicate);
} catch (...) {
std::string resolvedPre = MacroExpansion::expand(predicate, assay);
if (operation == setOperation) {
targetValue = resolvedPre;
} else {
int pre = 0;
try {
pre = stoi(MacroExpansion::expand(predicate, assay));
pre = stoi(resolvedPre);
} catch (...) {
pre = 0;
}
}
switch (operation) {
case setOperation:
targetValue = MacroExpansion::expand(predicate, assay);
break;
case sumAndSetOperation:
targetValue = std::to_string(value + pre);
break;
case substractAndSetOperation:
targetValue = std::to_string(value - pre);
break;
case setToOne:
targetValue = std::string("1");
break;
switch (operation) {
case sumAndSetOperation:
targetValue = std::to_string(value + pre);
break;
case substractAndSetOperation:
targetValue = std::to_string(value - pre);
break;
case setToOne:
targetValue = std::string("1");
break;
}
}
#ifndef NO_LOGS