···2929 let@ prefix', key = Option.bind @@ URI_scheme.split_addr uri in
3030 if prefix = prefix' then Some key else None
3131 in
3232- let last_sequential =
3333- List.fold_left
3434- (fun acc_i i ->
3535- if i > acc_i then i else acc_i
3636- )
3737- 0
3838- keys
3939- in
4032 let next =
4133 match mode with
4242- | `Sequential -> last_sequential + 1
3434+ | `Sequential ->
3535+ let last_sequential = List.fold_left (fun acc_i i -> if i > acc_i then i else acc_i ) 0 keys in
3636+ last_sequential + 1
4337 | `Random -> random_not_in keys
4438 in
4539 (match prefix with (None | Some "") -> "" | Some prefix -> prefix ^ "-") ^ BaseN.Base36.string_of_int next
+3-7
lib/core/URI_scheme.ml
···3535 match String.rindex_opt name '-' with
3636 | Some i ->
3737 let prefix = String.sub name 0 i
3838- and suffix = String.sub name (i + 1) (String.length name - i - 1)
3939- in
4040- begin
4141- match BaseN.Base36.int_of_string suffix with
4242- | Some key -> Some (Some prefix, key)
4343- | None -> None
4444- end
3838+ and suffix = String.sub name (i + 1) (String.length name - i - 1) in
3939+ let@ key = Option.map @~ BaseN.Base36.int_of_string suffix in
4040+ Some prefix, key
4541 | _ ->
4642 let@ key = Option.map @~ BaseN.Base36.int_of_string name in
4743 None, key