From 0898b70e97b90e09780699e74fcd4d94ba46bb90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Reynir=20Bj=C3=B6rnsson?= Date: Thu, 14 Mar 2024 13:20:27 +0100 Subject: [PATCH] Hoist out skip_whitespace branching in count_hex_chars --- ohex.ml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ohex.ml b/ohex.ml index 3d33253..1f856e8 100644 --- a/ohex.ml +++ b/ohex.ml @@ -9,12 +9,12 @@ let is_space = function | _ -> false let count_hex_chars ?(skip_whitespace = true) src = - string_fold (fun r c -> - if skip_whitespace && is_space c then - r - else - succ r) + if skip_whitespace then + string_fold (fun r c -> + if is_space c then r else succ r) 0 src / 2 + else + String.length src / 2 let decode_into ?(skip_whitespace = true) src tgt ?(off = 0) () = let fold f acc str =