mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-09-29 19:24:29 +03:00
Improve performance of VariableOrigin instances
- The previous approach would create a std::unique_ptr and store it in a std::list in VariableValue (Origins) - The new approach now stores Origins in a std::vector and constructs VariableOrigin elements in-place on insertion. - Instead of having two heap-allocations for every added VariableOrigin instance, this performs only one. - If multiple origins are added, std::vector's growth strategy may even prevent a heap-allocation. There's a cost on growing the size of the vector, because a copy of current elements will be necessary. - Introduced reserveOrigin method to notify that multiple insertions will be made, so that we can use std::vector's reserve and do a single allocation (and copy of previous elements), and then just initialize the new elements in-place.
This commit is contained in:
@@ -63,7 +63,7 @@ class AnchoredVariable {
|
||||
void append(const std::string &a, size_t offset,
|
||||
bool spaceSeparator = false);
|
||||
void append(const std::string &a, size_t offset,
|
||||
bool spaceSeparator, int size);
|
||||
bool spaceSeparator, size_t size);
|
||||
|
||||
void evaluate(std::vector<const VariableValue *> *l);
|
||||
std::string * evaluate();
|
||||
|
Reference in New Issue
Block a user