From: Sergey Matveev Date: Sat, 30 Nov 2024 22:29:00 +0000 (+0300) Subject: Another compare optimisation X-Git-Tag: v0.0.0~289 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=1a332ab023cf4436bfe8390d7095ace7d7fba4281fc4067e2fa7d27efbd4de4e;p=keks.git Another compare optimisation Instead of always checking of the length, do it only when error happens. --- diff --git a/pyac/pyac.py b/pyac/pyac.py index 59c038f..4cb9c53 100755 --- a/pyac/pyac.py +++ b/pyac/pyac.py @@ -375,9 +375,9 @@ def loads(v, sets=False, leapsecUTCAllow=False): break if not isinstance(k, str): raise DecodeError("non-string key") - if len(k) == 0: - raise DecodeError("empty key") if (len(k) < len(kPrev)) or ((len(k) == len(kPrev)) and (k <= kPrev)): + if len(k) == 0: + raise DecodeError("empty key") raise DecodeError("unsorted keys") i, v = loads(v, sets=sets) if i == _EOC: