Skip to content

Commit

Permalink
refactor(pkg): apply @talex5 optimization
Browse files Browse the repository at this point in the history
Documented in https://roscidus.com/blog/blog/2024/07/22/performance-2/

Signed-off-by: Rudi Grinberg <[email protected]>

<!-- ps-id: c607e4a6-19fa-4c26-bcdd-f356317868cd -->

Signed-off-by: Rudi Grinberg <[email protected]>
  • Loading branch information
rgrinberg committed Jan 14, 2025
1 parent 3e0def1 commit 3444f01
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions vendor/opam/src/core/opamVersionCompare.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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 ""
Expand Down

0 comments on commit 3444f01

Please sign in to comment.