Cache dispatch table between expr parses
authorEli Bendersky <eliben@gmail.com>
Sat, 14 Mar 2020 12:37:53 +0000 (05:37 -0700)
committerEli Bendersky <eliben@gmail.com>
Sat, 14 Mar 2020 12:37:53 +0000 (05:37 -0700)
commit2c8f7dc9b51df9448e74e730f787e7db9db0ef19
treeeb2245221c68c8cc62fb5000a8def9073365fd3c
parent79dd5d5b5453609f3495485dd8c43ad3d650b6c6
Cache dispatch table between expr parses

In descriptions, ExprDumper invokes parse_expr many times on small
expressions. Initializing the dispatch table for every parse is
wasteful.

Wrap parse_expr with a simple object that generates and caches the
dispatch table during initialization. parse_expr remains stateless.

Updates #298
elftools/dwarf/descriptions.py
elftools/dwarf/dwarf_expr.py
test/test_dwarf_expr.py