From 6509b671f7abbf888c74713188d05b89df96e518 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Tue, 14 Jan 2025 22:37:57 +0000 Subject: [PATCH] refactor(pkg): apply @talex5 optimization (#11294) Documented in https://roscidus.com/blog/blog/2024/07/22/performance-2/ Signed-off-by: Rudi Grinberg --- vendor/opam/src/core/opamVersionCompare.ml | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/vendor/opam/src/core/opamVersionCompare.ml b/vendor/opam/src/core/opamVersionCompare.ml index 9fefb43c24c..7e466c67eef 100644 --- a/vendor/opam/src/core/opamVersionCompare.ml +++ b/vendor/opam/src/core/opamVersionCompare.ml @@ -20,12 +20,9 @@ let is_digit = function (* [skip_while_from i f w m] yields the index of the leftmost character * in the string [s], starting from [i], and ending at [m], that does * not satisfy the predicate [f], or [length w] if no such index exists. *) -let skip_while_from i f w m = - let rec loop i = - if i = m then i - else if f w.[i] then loop (i + 1) else i - in loop i -;; +let rec skip_while_from i f w m = + if i = m then i + else if f w.[i] then skip_while_from (i + 1) f w m else i (* splits a version into (epoch,rest), without the separating ':'. The * epoch is delimited by the leftmost occurrence of ':' in x, and is ""