From d8d969a76e86012b609b331d7d6bb9bc34be2e3d Mon Sep 17 00:00:00 2001 From: Thomas Gazagnaire Date: Fri, 18 Dec 2020 14:24:50 +0100 Subject: [PATCH] Improve performance for encoding varints --- CHANGES.md | 9 ++++++--- src/repr/type_binary.ml | 6 +++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 3760ec36..30557374 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,8 +1,11 @@ ### 0.2.0 (2020-12-18) -- Improve performance of variable-size integers encoding. (#24, @samoht) -- Require `short_hash` operations to be explicitly unstaged. (#15, @CraigFe) -- Require `equal` and `compare` operations to be explicitly unstaged. (#16, @samoht) +- Improve performance of variable-size integers encoding and decoding. + (#24, #30, @samoht) +- Require `short_hash` operations to be explicitly unstaged. + (#15, @CraigFe) +- Require `equal` and `compare` operations to be explicitly unstaged. + (#16, @samoht) ### 0.1.0 (2020-10-16) diff --git a/src/repr/type_binary.ml b/src/repr/type_binary.ml index 11796bee..b2a8f84c 100644 --- a/src/repr/type_binary.ml +++ b/src/repr/type_binary.ml @@ -50,14 +50,14 @@ module Encode = struct let bool b = char (if b then '\255' else '\000') let int i k = - let rec aux n = + let rec aux n k = if n >= 0 && n < 128 then k chars.(n) else let out = 128 lor (n land 127) in k chars.(out); - aux (n lsr 7) + aux (n lsr 7) k in - aux i + aux i k let len n i = match n with