[pypy-svn] pypy jit-lsprofile: another pure function

cfbolz commits-noreply at bitbucket.org
Tue Jan 4 01:13:09 CET 2011


Author: Carl Friedrich Bolz <cfbolz at gmx.de>
Branch: jit-lsprofile
Changeset: r40364:89a5853f2937
Date: 2011-01-04 01:04 +0100
http://bitbucket.org/pypy/pypy/changeset/89a5853f2937/

Log:	another pure function

diff --git a/pypy/module/_lsprof/interp_lsprof.py b/pypy/module/_lsprof/interp_lsprof.py
--- a/pypy/module/_lsprof/interp_lsprof.py
+++ b/pypy/module/_lsprof/interp_lsprof.py
@@ -102,13 +102,15 @@
         return space.wrap(w_se)
 
     @jit.purefunction
-    def _get_or_make_subentry(self, entry):
+    def _get_or_make_subentry(self, entry, make=True):
         try:
             return self.calls[entry]
         except KeyError:
-            subentry = ProfilerSubEntry(entry.frame)
-            self.calls[entry] = subentry
-            return subentry
+            if make:
+                subentry = ProfilerSubEntry(entry.frame)
+                self.calls[entry] = subentry
+                return subentry
+            return None
 
 class ProfilerSubEntry(object):
     def __init__(self, frame):
@@ -152,11 +154,8 @@
         entry.callcount += 1
         if profobj.subcalls and self.previous:
             caller = self.previous.entry
-            try:
-                subentry = caller.calls[entry]
-            except KeyError:
-                pass
-            else:
+            subentry = caller._get_or_make_subentry(entry, False)
+            if subentry is not None:
                 subentry.recursionLevel -= 1
                 if subentry.recursionLevel == 0:
                     subentry.tt += tt


More information about the Pypy-commit mailing list