mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-10-01 12:07:46 +03:00
Minor performance improvements setting up intervention's log
- Initialize `log` temporary value on construction instead of doing default initialization and then calling `append`. - Leverage `std::string_view` to replace `const std::string&` parameters in `utils::string::replaceAll` to avoid creating a `std::string` object (and associated allocation and copy) for the string literal`%d`
This commit is contained in:
@@ -1492,9 +1492,8 @@ bool Transaction::intervention(ModSecurityIntervention *it) {
|
||||
it->status = m_it.status;
|
||||
|
||||
if (m_it.log != NULL) {
|
||||
std::string log("");
|
||||
log.append(m_it.log);
|
||||
utils::string::replaceAll(&log, std::string("%d"),
|
||||
std::string log(m_it.log);
|
||||
utils::string::replaceAll(log, "%d",
|
||||
std::to_string(it->status));
|
||||
it->log = strdup(log.c_str());
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user