diff options
author | Ilya Etingof <etingof@gmail.com> | 2017-08-25 00:33:28 +0200 |
---|---|---|
committer | Ilya Etingof <etingof@gmail.com> | 2017-08-25 00:33:28 +0200 |
commit | e2e1693e54728bafc580fd485842f74538026903 (patch) | |
tree | da2128e3628cbf6a88413cb626c6b0815d21062a /pyasn1/type | |
parent | 90a1fa1e53ea96a9dd0bbaa34e34a3e26b491e25 (diff) | |
download | pyasn1-e2e1693e54728bafc580fd485842f74538026903.tar.gz |
fix to exponential index growth at NamedTypes
Diffstat (limited to 'pyasn1/type')
-rw-r--r-- | pyasn1/type/namedtype.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/pyasn1/type/namedtype.py b/pyasn1/type/namedtype.py index 25e07a2..bc541db 100644 --- a/pyasn1/type/namedtype.py +++ b/pyasn1/type/namedtype.py @@ -106,13 +106,13 @@ class NamedTypes(object): ---------- *namedTypes: :class:`~pyasn1.type.namedtype.NamedType` """ - def __init__(self, *namedTypes): + def __init__(self, *namedTypes, **kwargs): self.__namedTypes = namedTypes self.__namedTypesLen = len(self.__namedTypes) self.__minTagSet = self.__computeMinTagSet() self.__nameToPosMap = self.__computeNameToPosMap() self.__tagToPosMap = self.__computeTagToPosMap() - self.__ambiguousTypes = self.__computeAmbiguousTypes() + self.__ambiguousTypes = 'terminal' not in kwargs and self.__computeAmbiguousTypes() or {} self.__uniqueTagMap = self.__computeTagMaps(unique=True) self.__nonUniqueTagMap = self.__computeTagMaps(unique=False) self.__hasOptionalOrDefault = bool([True for namedType in self.__namedTypes @@ -229,7 +229,7 @@ class NamedTypes(object): if len(partialAmbigiousTypes) == len(self.__namedTypes): ambigiousTypes[idx] = self else: - ambigiousTypes[idx] = NamedTypes(*partialAmbigiousTypes) + ambigiousTypes[idx] = NamedTypes(*partialAmbigiousTypes, terminal=True) return ambigiousTypes def getTypeByPosition(self, idx): @@ -394,13 +394,16 @@ class NamedTypes(object): minTagSet = None for namedType in self.__namedTypes: asn1Object = namedType.asn1Object + try: tagSet = asn1Object.minTagSet except AttributeError: tagSet = asn1Object.tagSet + if minTagSet is None or tagSet < minTagSet: minTagSet = tagSet + return minTagSet or tag.TagSet() @property |