From 1a332ab023cf4436bfe8390d7095ace7d7fba4281fc4067e2fa7d27efbd4de4e Mon Sep 17 00:00:00 2001 From: Sergey Matveev Date: Sun, 1 Dec 2024 01:29:00 +0300 Subject: [PATCH] Another compare optimisation Instead of always checking of the length, do it only when error happens. --- pyac/pyac.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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: -- 2.50.0