Huge performance improvement: passing variables as pointers avoiding copies

This commit is contained in:
Felipe Zimmerle
2015-09-18 20:21:12 -03:00
parent 2451bf05d7
commit 076a02951c
45 changed files with 207 additions and 208 deletions

View File

@@ -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

View File

@@ -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];
};