mirror of https://github.com/cool-RR/PySnooper.git
Optimisation: return None when not tracing frame to avoid line events
This commit is contained in:
parent
7ac2d59624
commit
b5b08f334e
|
@ -242,20 +242,20 @@ class Tracer:
|
||||||
# We did the most common and quickest check above, because the
|
# We did the most common and quickest check above, because the
|
||||||
# trace function runs so incredibly often, therefore it's
|
# trace function runs so incredibly often, therefore it's
|
||||||
# crucial to hyper-optimize it for the common case.
|
# crucial to hyper-optimize it for the common case.
|
||||||
return self.trace
|
return None
|
||||||
elif self._is_internal_frame(frame):
|
elif self._is_internal_frame(frame):
|
||||||
return self.trace
|
return None
|
||||||
else:
|
else:
|
||||||
_frame_candidate = frame
|
_frame_candidate = frame
|
||||||
for i in range(1, self.depth):
|
for i in range(1, self.depth):
|
||||||
_frame_candidate = _frame_candidate.f_back
|
_frame_candidate = _frame_candidate.f_back
|
||||||
if _frame_candidate is None:
|
if _frame_candidate is None:
|
||||||
return self.trace
|
return None
|
||||||
elif self._should_trace_frame(_frame_candidate):
|
elif self._should_trace_frame(_frame_candidate):
|
||||||
indent = ' ' * 4 * i
|
indent = ' ' * 4 * i
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
return self.trace
|
return None
|
||||||
else:
|
else:
|
||||||
indent = ''
|
indent = ''
|
||||||
# #
|
# #
|
||||||
|
|
Loading…
Reference in New Issue