Commit ffb4b3eb authored by W. Trevor King's avatar W. Trevor King
Browse files

Avoid expensive pformating in DynamicStructure.unpack_stream unless required.

If we're not going to be printing the formatted data in the log, don't
bother calculating it.  On my system, this speeds up the loading of
polar-graphs-demo.pxp by a factor of 10.
parent fe7006e3
......@@ -717,7 +717,8 @@ class DynamicStructure (Structure):
for f in self.fields:
_LOG.debug('parsing {!r}.{} (count={}, item_count={})'.format(
self, f, f.count, f.item_count))
if _LOG.level <= _logging.DEBUG:
if hasattr(f, 'pre_unpack'):
_LOG.debug('pre-unpack {}'.format(f))
f.pre_unpack(parents=parents, data=data)
Supports Markdown
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