llvm-project
f2c268f9 - [ImmutableSet] Optimize add/remove operations to avoid redundant tree modifications (#159845)

Commit
89 days ago
[ImmutableSet] Optimize add/remove operations to avoid redundant tree modifications (#159845) Optimize ImmutableSet operations to avoid unnecessary tree modifications when adding existing elements or removing non-existent elements. - Modified `ImutAVLFactory::add_internal()` to return the original tree when both key and value are the same, avoiding unnecessary node creation - Updated `ImutAVLFactory::remove_internal()` and `add_internal()` to return the original tree when no changes are made. Note that `balanceTree` always end up creating at least one node even when no rebalancing is done. So we also need to avoid unnecessary calls to it.
Author
Parents
Loading