Skip to content

Commit

Permalink
Merge pull request #6144 from talex5/compare-fewer-alloc
Browse files Browse the repository at this point in the history
Reduce allocations in opamVersionCompare
  • Loading branch information
kit-ty-kate authored Aug 7, 2024
2 parents 73a686a + cf351c6 commit 6effccc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
1 change: 1 addition & 0 deletions master_changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 3 additions & 5 deletions src/core/opamVersionCompare.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6effccc

Please sign in to comment.