Changeset: acfe93f09b39 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=acfe93f09b39
Modified Files:
        buildtools/autogen/autogen/codegen.py
Branch: Oct2010
Log Message:

Significantly increased speed of autogen.
It is not a good idea to use re.match and re.sub to match/substitute
constant strings: these functions are only useful for
matching/substituting regular expressions.  By using string methods,
we get a huge speed increase.


diffs (34 lines):

diff -r 7ed4f7f64b81 -r acfe93f09b39 buildtools/autogen/autogen/codegen.py
--- a/buildtools/autogen/autogen/codegen.py     Fri Dec 17 14:22:33 2010 +0100
+++ b/buildtools/autogen/autogen/codegen.py     Mon Dec 20 17:53:14 2010 +0100
@@ -306,16 +306,14 @@
                 subsrc = ''
                 subins = ''
                 for src,install in incdirsmap:
-                    m = re.match(re.escape(src),inc)
-                    if m and m.end() > mlen:
-                        mlen = m.end()
+                    slen = len(src)
+                    if slen > mlen and inc.startswith(src):
+                        mlen = slen
                         subsrc = src
                         subins = install
 
                 if mlen > 0:
-                    inc = re.sub(re.escape(subsrc),
-                                 re.escape(re.sub('includedir', '..', subins)),
-                                 inc)
+                    inc.replace(subsrc, subins.replace('includedir', '..'))
                 nvals.append(inc)
         installincs[k] = nvals
     installincs.close()
@@ -468,8 +466,7 @@
 
         if os.environ.has_key( var ):
             value = os.environ[var]
-            value = re.sub('\\{', '(', value)
-            value = re.sub('\\}', ')', value)
+            value = value.replace('{', '(').replace('}', ')')
             return value + rest
     return None
 
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to