Skip to content

Commit

Permalink
Use Bytes.unsafe_ variants in MemoryStore.
Browse files Browse the repository at this point in the history
This prevents unnecessarily allocating new strings when converting
from/to strings inside the MemoryStore.
  • Loading branch information
zoj613 committed Oct 21, 2024
1 parent 61ee346 commit ddd3428
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions zarr/src/storage/memory.ml
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ module Make (Deferred : Types.Deferred) = struct
let f = if append || ov = String.empty then
fun acc (_, v) -> acc ^ v else
fun acc (rs, v) ->
let s = Bytes.of_string acc in
let s = Bytes.unsafe_of_string acc in
Bytes.blit_string v 0 s rs String.(length v);
Bytes.to_string s
Bytes.unsafe_to_string s
in
let m' = M.add key (List.fold_left f ov rv) m in
if Atomic.compare_and_set t m m'
Expand Down

0 comments on commit ddd3428

Please sign in to comment.