mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-11-19 10:44:25 +03:00
Huge performance improvement: passing variables as pointers avoiding copies
This commit is contained in:
@@ -35,24 +35,18 @@ namespace transformations {
|
||||
|
||||
std::string RemoveNulls::evaluate(std::string value,
|
||||
Assay *assay) {
|
||||
int64_t i, j;
|
||||
int64_t i;
|
||||
|
||||
char *input = reinterpret_cast<char *>(malloc(value.size()
|
||||
* sizeof(char)));
|
||||
memcpy(input, value.c_str(), value.size());
|
||||
std::string ret;
|
||||
|
||||
i = j = 0;
|
||||
i = 0;
|
||||
while (i < value.size()) {
|
||||
if (input[i] != '\0') {
|
||||
input[j] = input[i];
|
||||
j++;
|
||||
if (value.at(i) != '\0') {
|
||||
ret += value.at(i);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
std::string ret(input, 0, j);
|
||||
free(input);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user