Commit 5c04c6c7 authored by Raphaël Proust's avatar Raphaël Proust

Stdlib/TzString: optimise is_hex

The function used to loop through calls to `get` (via the `.[]` syntax).
All the calls included bound-checks even though they were correct by
construction.

The function now calls `String.iter` which doesn't perform bound
checking.
parent 8ded98ea
......@@ -80,12 +80,8 @@ let is_hex s =
len mod 2 = 0
&&
try
for i = 0 to len - 1 do
match s.[i] with
| '0' .. '9' | 'a' .. 'f' | 'A' .. 'F' ->
()
| _ ->
raise Exit
done ;
String.iter
(function '0' .. '9' | 'a' .. 'f' | 'A' .. 'F' -> () | _ -> raise Exit)
s ;
true
with Exit -> false
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment