Skip to content

Commit

Permalink
Initialise Imperative priority queue array on creation
Browse files Browse the repository at this point in the history
No need to wait.

Signed-off-by: Frediano Ziglio <[email protected]>
  • Loading branch information
freddy77 committed Dec 3, 2024
1 parent 1a8a1f3 commit 3202058
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions ocaml/libs/xapi-stdext/lib/xapi-stdext-threads/ipq.ml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ let create n default =
invalid_arg "create"
else
let default = {ev= default; time= Mtime_clock.now ()} in
{default; size= -n; data= [||]}
{default; size= 0; data= Array.make n default}

let is_empty h = h.size <= 0

Expand All @@ -38,11 +38,6 @@ let resize h =
h.data <- d'

let add h x =
(* first addition: we allocate the array *)
if h.size < 0 then (
h.data <- Array.make (-h.size) h.default ;
h.size <- 0
) ;
let n = h.size in
(* resizing if needed *)
if n = Array.length h.data then resize h ;
Expand Down

0 comments on commit 3202058

Please sign in to comment.