Skip to content

Commit

Permalink
CA-400560: Avoid recomputing regex
Browse files Browse the repository at this point in the history
Use a closure to define the function. Then the var is evaluated
when the closure is defined. This can avoid recomputing the
parameter.

Signed-off-by: Changlei Li <[email protected]>
  • Loading branch information
changlei-li committed Oct 31, 2024
1 parent c80021b commit b138c57
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ocaml/xapi/rpm.ml
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,9 @@ module Pkg = struct
| _, Tilde ->
GT

let split_version_string s =
let split_version_string =
let r = Re.Posix.compile_pat {|[a-zA-Z]+|[0-9]+|~|} in
s |> Re.all r |> List.map (fun g -> Re.Group.get g 0)
fun s -> s |> Re.all r |> List.map (fun g -> Re.Group.get g 0)

let normalize v =
let version_segment_of_string = function
Expand Down

0 comments on commit b138c57

Please sign in to comment.