Commit 12c9562
authored
Rollup merge of #66648 - crgl:btree-clone-from, r=Amanieu
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
+106
-9
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
207 | 207 | | |
208 | 208 | | |
209 | 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 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
210 | 264 | | |
211 | 265 | | |
212 | 266 | | |
| |||
1357 | 1411 | | |
1358 | 1412 | | |
1359 | 1413 | | |
1360 | | - | |
| 1414 | + | |
| 1415 | + | |
| 1416 | + | |
| 1417 | + | |
1361 | 1418 | | |
1362 | 1419 | | |
1363 | 1420 | | |
| |||
1736 | 1793 | | |
1737 | 1794 | | |
1738 | 1795 | | |
1739 | | - | |
| 1796 | + | |
| 1797 | + | |
| 1798 | + | |
| 1799 | + | |
| 1800 | + | |
| 1801 | + | |
| 1802 | + | |
| 1803 | + | |
1740 | 1804 | | |
1741 | 1805 | | |
1742 | 1806 | | |
| |||
1745 | 1809 | | |
1746 | 1810 | | |
1747 | 1811 | | |
1748 | | - | |
| 1812 | + | |
| 1813 | + | |
| 1814 | + | |
| 1815 | + | |
| 1816 | + | |
1749 | 1817 | | |
1750 | 1818 | | |
1751 | 1819 | | |
1752 | 1820 | | |
1753 | 1821 | | |
1754 | 1822 | | |
1755 | 1823 | | |
1756 | | - | |
1757 | | - | |
| 1824 | + | |
1758 | 1825 | | |
1759 | 1826 | | |
1760 | 1827 | | |
| |||
1768 | 1835 | | |
1769 | 1836 | | |
1770 | 1837 | | |
1771 | | - | |
1772 | | - | |
| 1838 | + | |
1773 | 1839 | | |
1774 | 1840 | | |
1775 | 1841 | | |
| |||
1783 | 1849 | | |
1784 | 1850 | | |
1785 | 1851 | | |
1786 | | - | |
| 1852 | + | |
1787 | 1853 | | |
1788 | 1854 | | |
1789 | 1855 | | |
| |||
| 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 | |
|---|---|---|---|
| |||
785 | 785 | | |
786 | 786 | | |
787 | 787 | | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
788 | 808 | | |
789 | 809 | | |
790 | 810 | | |
| |||
0 commit comments