don't try to hash value if enum is empty

Very few tags have an enum, and for those who don't, computing the hash value can be very expensive, e.g. instances of `fractions.Fraction` as mentioned in [the source](https://github.com/python/cpython/blob/master/Lib/fractions.py#L543).
This commit is contained in:
Glandos 2018-12-20 16:07:03 +01:00 committed by GitHub
parent 9dd0348be2
commit e37b3fb7d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -29,7 +29,7 @@ class TagInfo(namedtuple("_TagInfo", "value name type length enum")):
cls, value, name, type, length, enum or {})
def cvt_enum(self, value):
return self.enum.get(value, value)
return self.enum.get(value, value) if self.enum else value
def lookup(tag):