File tree Expand file tree Collapse file tree 1 file changed +13
-8
lines changed Expand file tree Collapse file tree 1 file changed +13
-8
lines changed Original file line number Diff line number Diff line change @@ -270,17 +270,22 @@ and balance version = function
270
270
else (node.version < - version; node.size < - 1 + sl + sr; self)
271
271
)
272
272
273
- let rec _compute_sub_size1 version = function
273
+ let rec compute_sub_size version = function
274
274
| Root _ -> ()
275
275
| Leaf -> ()
276
276
| Node node as self ->
277
- if node.size = 0 then begin
278
- _compute_sub_size1 version node.left;
279
- _compute_sub_size1 version node.right;
280
- ignore (balance version self)
281
- end
282
-
283
- let compute_sub_size = _compute_sub_size1
277
+ if node.size = 0 then
278
+ match node.left with
279
+ | Node {size = 0 ; _} ->
280
+ compute_sub_size version node.left
281
+ | _ ->
282
+ match node.right with
283
+ | Node {size = 0 ; _} ->
284
+ compute_sub_size version node.right
285
+ | _ ->
286
+ let parent = node.parent in
287
+ ignore (balance version self);
288
+ compute_sub_size version parent
284
289
285
290
let rec reset_version version = function
286
291
| Leaf -> ()
You can’t perform that action at this time.
0 commit comments