Commit 633e948
committed
Auto merge of #66648 - crgl:btree-clone-from, r=<try>
Implement clone_from for BTreeMap and BTreeSet
See #28481. This results in up to 90% speedups on simple data types when `self` and `other` are the same size, and is generally comparable or faster. Some concerns:
1. This implementation requires an `Ord` bound on the `Clone` implementation for `BTreeMap` and `BTreeSet`. Since these structs can only be created externally for keys with `Ord` implemented, this should be fine? If not, there's certainly a less safe way to do this.
2. Changing `next_unchecked` on `RangeMut` to return mutable key references allows for replacing the entire overlapping portion of both maps without changing the external interface in any way. However, if `clone_from` fails it can leave the `BTreeMap` in an invalid state, which might be unacceptable.
This probably needs an FCP since it changes a trait bound, but (as far as I know?) that change cannot break any external code.3 files changed
+74
-15
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
135 | 135 | | |
136 | 136 | | |
137 | 137 | | |
138 | | - | |
| 138 | + | |
139 | 139 | | |
140 | 140 | | |
141 | 141 | | |
| |||
201 | 201 | | |
202 | 202 | | |
203 | 203 | | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | | - | |
208 | | - | |
209 | | - | |
| 204 | + | |
210 | 205 | | |
211 | 206 | | |
212 | 207 | | |
213 | 208 | | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
214 | 238 | | |
215 | 239 | | |
216 | 240 | | |
| |||
1364 | 1388 | | |
1365 | 1389 | | |
1366 | 1390 | | |
1367 | | - | |
| 1391 | + | |
| 1392 | + | |
| 1393 | + | |
| 1394 | + | |
1368 | 1395 | | |
1369 | 1396 | | |
1370 | 1397 | | |
| |||
1761 | 1788 | | |
1762 | 1789 | | |
1763 | 1790 | | |
1764 | | - | |
| 1791 | + | |
| 1792 | + | |
| 1793 | + | |
| 1794 | + | |
1765 | 1795 | | |
1766 | 1796 | | |
1767 | 1797 | | |
| |||
1771 | 1801 | | |
1772 | 1802 | | |
1773 | 1803 | | |
1774 | | - | |
| 1804 | + | |
1775 | 1805 | | |
1776 | 1806 | | |
1777 | 1807 | | |
1778 | 1808 | | |
1779 | 1809 | | |
1780 | 1810 | | |
1781 | 1811 | | |
1782 | | - | |
1783 | | - | |
| 1812 | + | |
1784 | 1813 | | |
1785 | 1814 | | |
1786 | 1815 | | |
| |||
1794 | 1823 | | |
1795 | 1824 | | |
1796 | 1825 | | |
1797 | | - | |
1798 | | - | |
| 1826 | + | |
1799 | 1827 | | |
1800 | 1828 | | |
1801 | 1829 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
59 | | - | |
| 59 | + | |
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
65 | 76 | | |
66 | 77 | | |
67 | 78 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
552 | 552 | | |
553 | 553 | | |
554 | 554 | | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
555 | 575 | | |
556 | 576 | | |
557 | 577 | | |
| |||
0 commit comments