]> Cypherpunks repositories - keks.git/commitdiff
Yet another tiny optimisation
authorSergey Matveev <stargrave@stargrave.org>
Thu, 5 Dec 2024 10:43:41 +0000 (13:43 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Thu, 5 Dec 2024 10:43:41 +0000 (13:43 +0300)
pyac/pyac.py

index 300bc6754fa36cee288f77882509bd31570a1b2bd3c3b8d535dd64490685aa9b..0492841506bb65fcb50686822e0557a7bd6f909281173ab8bf0cff8c32c6cf69 100755 (executable)
@@ -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")