Skip to content

Commit f0af6fc

Browse files
committed
Apply loop unrolling to int encodings
1 parent 7cdec36 commit f0af6fc

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/ocaml_protoc_plugin/reader.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ let read_varint t =
4646
inner acc (Int.add bit 7)
4747
| false -> acc
4848
in
49-
inner 0L 0
49+
(inner[@unrolled 10]) 0L 0
5050

5151
let read_varint_unboxed t = read_varint t |> Int64.to_int
5252

src/ocaml_protoc_plugin/writer.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ let write_varint buffer ~offset v =
3838
Bytes.unsafe_set buffer offset ((v land 0x7fL) lor 0b1000_0000L |> Int64.to_int |> Char.unsafe_chr);
3939
inner ~offset:next_offset rem
4040
in
41-
inner ~offset v
41+
(inner[@unrolled 10]) ~offset v
4242

4343
let write_varint_unboxed buffer ~offset v = write_varint buffer ~offset (Int64.of_int v)
4444

0 commit comments

Comments
 (0)