summaryrefslogtreecommitdiffstats
path: root/tools/warn.py
diff options
context:
space:
mode:
authorMarco Nelissen <marcone@google.com>2009-09-29 10:19:29 -0700
committerMarco Nelissen <marcone@google.com>2009-09-29 10:19:29 -0700
commit2bdc7ec9cf274727e2d682d82ca7f8bd9ba42779 (patch)
tree4c6b8b7fb5434d187ece943e8f4d9c31ae0dc704 /tools/warn.py
parentd85472a7461d0daeb7e17a6f0a7c56f37a2335bc (diff)
downloadbuild-2bdc7ec9cf274727e2d682d82ca7f8bd9ba42779.zip
build-2bdc7ec9cf274727e2d682d82ca7f8bd9ba42779.tar.gz
build-2bdc7ec9cf274727e2d682d82ca7f8bd9ba42779.tar.bz2
Speed up warn.py about 30x by precompiling all the regular expressions.
Diffstat (limited to 'tools/warn.py')
-rwxr-xr-xtools/warn.py16
1 files changed, 9 insertions, 7 deletions
diff --git a/tools/warn.py b/tools/warn.py
index b379849..6fea20a 100755
--- a/tools/warn.py
+++ b/tools/warn.py
@@ -460,8 +460,8 @@ def dumpseverity(sev):
def classifywarning(line):
for i in warnpatterns:
- for pat in i['patterns']:
- if re.match(pat, line):
+ for cpat in i['compiledpatterns']:
+ if cpat.match(line):
i['members'].append(line)
return
else:
@@ -470,7 +470,12 @@ def classifywarning(line):
# 2 or more concurrent compiles
pass
-
+# precompiling every pattern speeds up parsing by about 30x
+def compilepatterns():
+ for i in warnpatterns:
+ i['compiledpatterns'] = []
+ for pat in i['patterns']:
+ i['compiledpatterns'].append(re.compile(pat))
infile = open(sys.argv[1], 'r')
warnings = []
@@ -481,6 +486,7 @@ targetvariant = 'unknown'
linecounter = 0
warningpattern = re.compile('.* warning:.*')
+compilepatterns()
# read the log file and classify all the warnings
lastmatchedline = ''
@@ -515,7 +521,3 @@ dumpseverity(severity.HARMLESS)
dumpseverity(severity.UNKNOWN)
dumpfixed()
-
-
-
-