mirror of
https://github.com/c-cube/sidekick.git
synced 2025-12-07 11:45:41 -05:00
perf(cc): path compression
This commit is contained in:
parent
ac030641db
commit
365aedb138
1 changed files with 4 additions and 3 deletions
|
|
@ -276,13 +276,14 @@ module Make(A: ARG) = struct
|
|||
let[@inline] mem (cc:t) (t:term): bool = T_tbl.mem cc.tbl t
|
||||
|
||||
(* find representative, recursively *)
|
||||
let[@unroll 1] rec find_rec (n:node) : repr =
|
||||
let[@unroll 2] rec find_rec (n:node) : repr =
|
||||
if n==n.n_root then (
|
||||
n
|
||||
) else (
|
||||
(* TODO: path compression, assuming backtracking restores equiv classes
|
||||
properly *)
|
||||
let root = find_rec n.n_root in
|
||||
if root != n.n_root then (
|
||||
n.n_root <- root; (* path compression *)
|
||||
);
|
||||
root
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue