From 501fd85fa1619a2600733d6d0df8fe0e05e57411 Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Tue, 22 Nov 2011 12:40:12 +0000 Subject: [PATCH] minor optimization --- lib/parse/handler.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/parse/handler.py b/lib/parse/handler.py index d40212fd3..6fc1f4a0f 100644 --- a/lib/parse/handler.py +++ b/lib/parse/handler.py @@ -45,7 +45,11 @@ class FingerprintHandler(ContentHandler): def startElement(self, name, attrs): if name == "regexp": self.__regexp = sanitizeStr(attrs.get("value")) - self.__match = re.search(self.__regexp, self.__banner, re.I | re.M) + _ = re.match("\A[A-Za-z0-9]+", self.__regexp) # minor trick avoiding compiling of large amount of regexes + if _ and _.group(0).lower() in self.__banner.lower() or not _: + self.__match = re.search(self.__regexp, self.__banner, re.I | re.M) + else: + self.__match = None if name == "info" and self.__match: self.__feedInfo("type", attrs.get("type"))