mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-11-19 02:40:35 +03:00
Huge performance improvement: passing variables as pointers avoiding copies
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user