diff --git a/master_changes.md b/master_changes.md index bae8e0d2f2b..ca710438b6a 100644 --- a/master_changes.md +++ b/master_changes.md @@ -121,6 +121,7 @@ users) ## Internal * Stop using polymorphic comparison when comparing `OpamTypes.switch_selections` [#6102 @kit-ty-kate] * Remove the meta opam packages opam and opam-admin [#6115 @kit-ty-kate] + * Reduce allocations in OpamVersionCompare [#6144 @talex5] ## Internal: Windows diff --git a/src/core/opamVersionCompare.ml b/src/core/opamVersionCompare.ml index 9fefb43c24c..9aa47372935 100644 --- a/src/core/opamVersionCompare.ml +++ b/src/core/opamVersionCompare.ml @@ -20,11 +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