Kaydet (Commit) 127ee160 authored tarafından Fred Drake's avatar Fred Drake

Minor cleanup:

- Add comment explaining the structure of the stack.
- Minor optimization: make stack tuple directly usable as part of return
  value for enter/exit events.
üst 187b1d82
...@@ -41,6 +41,12 @@ class LogReader: ...@@ -41,6 +41,12 @@ class LogReader:
self.cwd = self._info['current-directory'] self.cwd = self._info['current-directory']
else: else:
self.cwd = None self.cwd = None
# This mirrors the call stack of the profiled code as the log
# is read back in. It contains tuples of the form:
#
# (file name, line number of function def, function name)
#
self._stack = [] self._stack = []
self._append = self._stack.append self._append = self._stack.append
self._pop = self._stack.pop self._pop = self._stack.pop
...@@ -99,15 +105,15 @@ class LogReader: ...@@ -99,15 +105,15 @@ class LogReader:
if what == WHAT_ENTER: if what == WHAT_ENTER:
filename, funcname = self._decode_location(fileno, lineno) filename, funcname = self._decode_location(fileno, lineno)
self._append((filename, funcname, lineno)) t = (filename, lineno, funcname)
return what, (filename, lineno, funcname), tdelta self._append(t)
return what, t, tdelta
if what == WHAT_EXIT: if what == WHAT_EXIT:
filename, funcname, lineno = self._pop() return what, self._pop(), tdelta
return what, (filename, lineno, funcname), tdelta
if what == WHAT_LINENO: if what == WHAT_LINENO:
filename, funcname, firstlineno = self._stack[-1] filename, firstlineno, funcname = self._stack[-1]
return what, (filename, lineno, funcname), tdelta return what, (filename, lineno, funcname), tdelta
if what == WHAT_DEFINE_FILE: if what == WHAT_DEFINE_FILE:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment