From cade6e96853a3fa1af98a15180d013c8dd7a04db Mon Sep 17 00:00:00 2001 From: Christoph Reiter Date: Sat, 28 Jun 2025 20:52:13 +0200 Subject: [PATCH] vercmp: add fast path for when the versions or parts are equal We compare the same versions a lot, for example downstream with upstream, or git with pacman repo. --- app/utils.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/utils.py b/app/utils.py index 149fa56..c878278 100644 --- a/app/utils.py +++ b/app/utils.py @@ -22,6 +22,9 @@ logger.setLevel(logging.DEBUG) def vercmp(v1: str, v2: str) -> int: + if v1 == v2: + return 0 + def cmp(a: Any, b: Any) -> int: res = (a > b) - (a < b) assert isinstance(res, int) @@ -72,6 +75,9 @@ def vercmp(v1: str, v2: str) -> int: return parts def rpmvercmp(v1: str, v2: str) -> int: + if v1 == v2: + return 0 + for x1, x2 in zip_longest(parse(v1), parse(v2), fillvalue=None): if x1 is None: assert x2 is not None