From: Anders Dellien Date: Mon, 24 Dec 2018 16:56:52 +0000 (+0100) Subject: More efficient AbbrevDecl handling (#212) X-Git-Tag: v0.26~28 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ee37f4c569fa17df9041678c04bdb44b3f1fd38a;p=pyelftools.git More efficient AbbrevDecl handling (#212) Create all the AbbrevDecl objects during parsing and later return references to them - this gives a small performance gain. --- diff --git a/elftools/dwarf/abbrevtable.py b/elftools/dwarf/abbrevtable.py index 36f6d2a..6d29d5c 100644 --- a/elftools/dwarf/abbrevtable.py +++ b/elftools/dwarf/abbrevtable.py @@ -33,7 +33,7 @@ class AbbrevTable(object): """ Get the AbbrevDecl for a given code. Raise KeyError if no declaration for this code exists. """ - return AbbrevDecl(code, self._abbrev_map[code]) + return self._abbrev_map[code] def _parse_abbrev_table(self): """ Parse the abbrev table from the stream @@ -49,7 +49,7 @@ class AbbrevTable(object): declaration = struct_parse( struct=self.structs.Dwarf_abbrev_declaration, stream=self.stream) - map[decl_code] = declaration + map[decl_code] = AbbrevDecl(decl_code, declaration) return map