summaryrefslogtreecommitdiff
path: root/buildscripts
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2012-01-22 00:06:06 -0500
committerEliot Horowitz <eliot@10gen.com>2012-01-22 00:06:06 -0500
commit08eac1faf3c019c4678f8025f7ad433eb917073f (patch)
tree1e6cd7da6337eb9608d822cdaec309b5b47ad3eb /buildscripts
parentcde936c7cd7ad0db67f19224e9e971095d9f2ed6 (diff)
downloadmongo-08eac1faf3c019c4678f8025f7ad433eb917073f.tar.gz
improve scons invocation time by short circuiting regex
Diffstat (limited to 'buildscripts')
-rwxr-xr-xbuildscripts/errorcodes.py59
1 files changed, 35 insertions, 24 deletions
diff --git a/buildscripts/errorcodes.py b/buildscripts/errorcodes.py
index 86418523dcb..79f0f0fa154 100755
--- a/buildscripts/errorcodes.py
+++ b/buildscripts/errorcodes.py
@@ -32,6 +32,9 @@ def assignErrorCodes():
codes = []
def readErrorCodes( callback, replaceZero = False ):
+
+ quick = [ "assert" , "Exception" , "verify" ]
+
ps = [ re.compile( "(([umsg]asser(t|ted))) *\(( *)(\d+)" ) ,
re.compile( "((User|Msg|MsgAssertion)Exceptio(n))\(( *)(\d+)" ) ,
re.compile( "(((verify))) *\(( *)(\d+)" )
@@ -45,30 +48,38 @@ def readErrorCodes( callback, replaceZero = False ):
lineNum = 1
for line in open( x ):
-
- for p in ps:
-
- def repl( m ):
- m = m.groups()
-
- start = m[0]
- spaces = m[3]
- code = m[4]
- if code == '0' and replaceZero :
- code = getNextCode( lastCodes )
- lastCodes.append( code )
- code = str( code )
- needReplace[0] = True
-
- print( "Adding code " + code + " to line " + x + ":" + str( lineNum ) )
-
- else :
- codes.append( ( x , lineNum , line , code ) )
- callback( x , lineNum , line , code )
-
- return start + "(" + spaces + code
-
- line = re.sub( p, repl, line )
+
+ found = False
+ for zz in quick:
+ if line.find( zz ) >= 0:
+ found = True
+ break
+
+ if found:
+ for p in ps:
+
+ def repl( m ):
+ m = m.groups()
+
+ start = m[0]
+ spaces = m[3]
+ code = m[4]
+ if code == '0' and replaceZero :
+ code = getNextCode( lastCodes )
+ lastCodes.append( code )
+ code = str( code )
+ needReplace[0] = True
+
+ print( "Adding code " + code + " to line " + x + ":" + str( lineNum ) )
+
+ else :
+ codes.append( ( x , lineNum , line , code ) )
+ callback( x , lineNum , line , code )
+
+ return start + "(" + spaces + code
+
+ line = re.sub( p, repl, line )
+ # end if ps loop
if replaceZero : lines.append( line )
lineNum = lineNum + 1