Skip to content

Commit

Permalink
Compule length only once
Browse files Browse the repository at this point in the history
Simple optimisiation: compute the number of entries in omt only once.
This list has potentially millions of entries.

Signed-off-by: Christian Lindig <[email protected]>
  • Loading branch information
Christian Lindig committed Aug 11, 2023
1 parent c85fe48 commit 1438a4e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/rtree.ml
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,12 @@ module Make (E : Envelope) (V : Value with type envelope = E.t) = struct
|> Float.ceil |> int_of_float

let rec omt ~m entries =
if List.length entries <= m then
let length = List.length entries in
if length <= m then
let leaves = List.map (fun v -> (V.envelope v, v)) entries in
Leaf leaves
else
let slices = number_along_axis ~m (List.length entries) in
let slices = number_along_axis ~m length in
let q =
let q' = Queue.create () in
Queue.add (entries, E.dimensions - 1) q';
Expand Down

0 comments on commit 1438a4e

Please sign in to comment.