Commit f2c268f
authored
[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.1 parent b5c0102 commit f2c268f
File tree
3 files changed
+70
-22
lines changed- clang/lib/Analysis
- llvm
- include/llvm/ADT
- unittests/ADT
3 files changed
+70
-22
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
910 | 910 | | |
911 | 911 | | |
912 | 912 | | |
913 | | - | |
914 | | - | |
915 | 913 | | |
916 | 914 | | |
917 | 915 | | |
918 | | - | |
919 | | - | |
| 916 | + | |
920 | 917 | | |
921 | 918 | | |
922 | 919 | | |
| |||
950 | 947 | | |
951 | 948 | | |
952 | 949 | | |
953 | | - | |
954 | | - | |
955 | | - | |
956 | | - | |
| 950 | + | |
957 | 951 | | |
| 952 | + | |
| 953 | + | |
958 | 954 | | |
959 | 955 | | |
960 | 956 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
531 | 531 | | |
532 | 532 | | |
533 | 533 | | |
534 | | - | |
| 534 | + | |
535 | 535 | | |
536 | 536 | | |
537 | 537 | | |
538 | 538 | | |
539 | 539 | | |
540 | 540 | | |
541 | 541 | | |
542 | | - | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
543 | 548 | | |
544 | | - | |
545 | | - | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
546 | 555 | | |
547 | | - | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
548 | 563 | | |
549 | 564 | | |
550 | 565 | | |
551 | 566 | | |
552 | 567 | | |
553 | 568 | | |
554 | | - | |
| 569 | + | |
555 | 570 | | |
556 | 571 | | |
557 | 572 | | |
558 | 573 | | |
559 | 574 | | |
560 | 575 | | |
561 | 576 | | |
562 | | - | |
| 577 | + | |
563 | 578 | | |
564 | | - | |
565 | | - | |
566 | | - | |
567 | | - | |
568 | | - | |
569 | | - | |
570 | | - | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
571 | 592 | | |
572 | 593 | | |
573 | 594 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
164 | 164 | | |
165 | 165 | | |
166 | 166 | | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
167 | 197 | | |
| 198 | + | |
0 commit comments