mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-09-29 19:24:29 +03:00
Huge performance improvement: passing variables as pointers avoiding copies
This commit is contained in:
@@ -46,15 +46,13 @@ Regex::Regex(const std::string& pattern_)
|
||||
|
||||
int regex_search(const std::string& s, SMatch *match,
|
||||
const Regex& regex) {
|
||||
int *ovector = 0;
|
||||
int ovecsize = 0;
|
||||
return pcre_exec(regex.m_pc, regex.m_pce, s.c_str(), s.size(), 0, 0, ovector, ovecsize) > 0;
|
||||
int ovector[OVECCOUNT];
|
||||
return pcre_exec(regex.m_pc, regex.m_pce, s.c_str(), s.size(), 0, 0, ovector, OVECCOUNT) > 0;
|
||||
}
|
||||
|
||||
int regex_search(const std::string& s, const Regex& regex) {
|
||||
int *ovector = 0;
|
||||
int ovecsize = 0;
|
||||
return pcre_exec(regex.m_pc, regex.m_pce, s.c_str(), s.size(), 0, 0, ovector, ovecsize) > 0;
|
||||
int ovector[OVECCOUNT];
|
||||
return pcre_exec(regex.m_pc, regex.m_pce, s.c_str(), s.size(), 0, 0, ovector, OVECCOUNT) > 0;
|
||||
}
|
||||
|
||||
} // namespace Utils
|
||||
|
@@ -25,6 +25,7 @@
|
||||
namespace ModSecurity {
|
||||
namespace Utils {
|
||||
|
||||
#define OVECCOUNT 30
|
||||
|
||||
class Regex {
|
||||
public:
|
||||
@@ -32,7 +33,7 @@ class Regex {
|
||||
std::string pattern;
|
||||
pcre *m_pc = NULL;
|
||||
pcre_extra *m_pce = NULL;
|
||||
|
||||
int m_ovector[OVECCOUNT];
|
||||
};
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user