Author: Armin Rigo <[email protected]>
Branch: stmgc-c4
Changeset: r66803:4c03d4d79569
Date: 2013-09-05 16:09 +0200
http://bitbucket.org/pypy/pypy/changeset/4c03d4d79569/

Log:    Use a regexp to drop the "1#" at the start of stm pypylog files.
        Otherwise, it would drop everything before a "#" used as a comment.

diff --git a/rpython/jit/tool/loopcounter.py b/rpython/jit/tool/loopcounter.py
--- a/rpython/jit/tool/loopcounter.py
+++ b/rpython/jit/tool/loopcounter.py
@@ -7,6 +7,8 @@
 import optparse
 import re
 
+r_skip_thread = re.compile(r'^(\d+#)?')
+
 def get_timestamp(line):
     match = re.match(r'\[([0-9a-f]*)\] .*', line)
     return int(match.group(1), 16)
@@ -17,13 +19,13 @@
     time0 = None
     lines = iter(log)
     for line in lines:
-        line = line[line.find("#") + 1:].strip()
+        line = r_skip_thread.sub('', line).strip()
         if time0 is None and line.startswith('['):
             time0 = get_timestamp(line)
         if '{jit-mem-looptoken-' in line:
             time_now = get_timestamp(line) - time0
             text = lines.next()
-            text = text[text.find("#") + 1:].strip()
+            text = r_skip_thread.sub('', text).strip()
             if text.startswith('allocating Loop #'):
                 loops += 1
             elif text.startswith('allocating Bridge #'):
diff --git a/rpython/jit/tool/oparser.py b/rpython/jit/tool/oparser.py
--- a/rpython/jit/tool/oparser.py
+++ b/rpython/jit/tool/oparser.py
@@ -3,12 +3,15 @@
 in a nicer fashion
 """
 
+import re
 from rpython.jit.tool.oparser_model import get_model
-
 from rpython.jit.metainterp.resoperation import rop, ResOperation, \
                                             ResOpWithDescr, N_aryOp, \
                                             UnaryOp, PlainResOp
 
+r_skip_thread = re.compile(r'^(\d+#)?')
+
+
 class ParseError(Exception):
     pass
 
@@ -297,7 +300,7 @@
         newlines = []
         first_comment = None
         for line in lines:
-            line = line[line.find('#')+1:].strip()
+            line = r_skip_thread.sub('', line).strip()
             # for simplicity comments are not allowed on
             # debug_merge_point lines
             if '#' in line and 'debug_merge_point(' not in line:
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to