diff options
author | Eliot Horowitz <eliot@10gen.com> | 2012-01-22 00:06:06 -0500 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2012-01-22 00:06:06 -0500 |
commit | 08eac1faf3c019c4678f8025f7ad433eb917073f (patch) | |
tree | 1e6cd7da6337eb9608d822cdaec309b5b47ad3eb /buildscripts | |
parent | cde936c7cd7ad0db67f19224e9e971095d9f2ed6 (diff) | |
download | mongo-08eac1faf3c019c4678f8025f7ad433eb917073f.tar.gz |
improve scons invocation time by short circuiting regex
Diffstat (limited to 'buildscripts')
-rwxr-xr-x | buildscripts/errorcodes.py | 59 |
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 |