From 1e3629bc675d6d368048b0593563e02324cd9512 Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Wed, 25 Oct 2023 23:29:47 -0400 Subject: [PATCH] fix ws_deque: strict bound for shrinking --- src/ws_deque_.ml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ws_deque_.ml b/src/ws_deque_.ml index 378dc14e..f155aa85 100644 --- a/src/ws_deque_.ml +++ b/src/ws_deque_.ml @@ -89,10 +89,10 @@ let push (self : 'a t) (x : 'a) : unit = CA.set !arr b x; A.set self.bottom (b + 1) -let perhaps_shrink (self : _ t) arr ~top ~bottom : unit = +let maybe_shrink_ (self : _ t) arr ~top ~bottom : unit = let size = bottom - top in let ca_size = CA.size arr in - if ca_size >= 256 && size <= ca_size / 3 then + if ca_size >= 256 && size < ca_size / 3 then A.set self.arr (CA.shrink arr ~top ~bottom) let pop (self : 'a t) : 'a option = @@ -112,7 +112,7 @@ let pop (self : 'a t) : 'a option = ) else if size > 0 then ( (* can pop without modifying [top] *) let x = CA.get arr b in - perhaps_shrink self arr ~bottom:b ~top:t; + maybe_shrink_ self arr ~bottom:b ~top:t; Some x ) else ( assert (size = 0);