From 8ffcf6fc3d039d29294506dfe8309107e8b5f459 Mon Sep 17 00:00:00 2001 From: brain Date: Sat, 14 Apr 2007 12:05:27 +0000 Subject: Working in m_filter_pcre. Thanks DarkPrince (PingBad) for the idea we messed with - when a match is successful move that match to the head of the list (O(1) operation) The original suggestion was to sort, this would be far too expensive git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@6794 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/modules/extra/m_filter_pcre.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/modules/extra/m_filter_pcre.cpp b/src/modules/extra/m_filter_pcre.cpp index e35094ac0..8a3119f20 100644 --- a/src/modules/extra/m_filter_pcre.cpp +++ b/src/modules/extra/m_filter_pcre.cpp @@ -34,6 +34,10 @@ class PCREFilter : public FilterResult : FilterResult::FilterResult(pat, rea, act, gline_time), regexp(r) { } + + PCREFilter() + { + } }; class ModuleFilterPCRE : public FilterBase @@ -42,6 +46,7 @@ class ModuleFilterPCRE : public FilterBase pcre *re; const char *error; int erroffset; + PCREFilter fr; public: ModuleFilterPCRE(InspIRCd* Me) @@ -60,14 +65,13 @@ class ModuleFilterPCRE : public FilterBase { if (pcre_exec(index->regexp, NULL, text.c_str(), text.length(), 0, 0, NULL, 0) > -1) { - PCREFilter* fr = &(*index); + fr = *index; if (index != filters.begin()) { filters.erase(index); - filters.insert(filters.begin(), *fr); - index = filters.begin(); + filters.insert(filters.begin(), fr); } - return &(*index); + return &fr; } } return NULL; -- cgit v1.2.3