Skip to content

Commit

Permalink
[maintenance]: vhd_format_lwt_test: speed up by using Cstruct.compare
Browse files Browse the repository at this point in the history
Instead of comparing byte by byte use the more efficient comparison function
that cstruct provides.

This speeds up the test (from ~40s to ~33s).

Signed-off-by: Edwin Török <[email protected]>
  • Loading branch information
edwintorok committed Sep 9, 2024
1 parent a1f994a commit 30f24ac
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions ocaml/libs/vhd/vhd_format/f.ml
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,7 @@ exception Cstruct_differ
let cstruct_equal a b =
let check_contents a b =
try
for i = 0 to Cstruct.length a - 1 do
let a' = Cstruct.get_char a i in
let b' = Cstruct.get_char b i in
if a' <> b' then raise Cstruct_differ
done ;
if Cstruct.compare a b <> 0 then raise Cstruct_differ ;
true
with _ -> false
in
Expand Down

0 comments on commit 30f24ac

Please sign in to comment.