From: Sergey Matveev Date: Thu, 5 Dec 2024 10:43:41 +0000 (+0300) Subject: Yet another tiny optimisation X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=33eb37e976d046f54e8772b1b76a2fb37f5b9dd2697dff71e0936236f3f70d19;p=keks.git Yet another tiny optimisation --- diff --git a/pyac/pyac.py b/pyac/pyac.py index 300bc67..0492841 100755 --- a/pyac/pyac.py +++ b/pyac/pyac.py @@ -366,7 +366,9 @@ def _loads(v, sets=False, leapsecUTCAllow=False, _allowContainers=True): if b == TagNInt: i, v = _int(v[1:]) return (-1 - i), v - if (b == TagList) and _allowContainers: + if not _allowContainers: + raise DecodeError("unknown tag") + if b == TagList: ret = [] v = v[1:] while True: @@ -375,7 +377,7 @@ def _loads(v, sets=False, leapsecUTCAllow=False, _allowContainers=True): break ret.append(i) return ret, v - if (b == TagMap) and _allowContainers: + if b == TagMap: ret = {} v = v[1:] kPrev = "" @@ -400,7 +402,7 @@ def _loads(v, sets=False, leapsecUTCAllow=False, _allowContainers=True): if sets and allNILs: ret = set(ret.keys()) return ret, v - if (b == TagBlob) and _allowContainers: + if b == TagBlob: if len(v) < 1+8: raise NotEnoughData(1+8-len(v)) l = 1 + int.from_bytes(v[1:1+8], "big")