Commit 5f128ed
committed
Auto merge of #38017 - arthurprs:hm-extend, r=bluss
Smarter HashMap/HashSet pre-allocation for extend/from_iter
HashMap/HashSet from_iter and extend are making totally different assumptions.
A more balanced decision may allocate half the lower hint (rounding up). For "well defined" iterators this effectively limits the worst case to two resizes (the initial reserve + one resize).
cc #36579
cc @bluss2 files changed
+16
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1974 | 1974 | | |
1975 | 1975 | | |
1976 | 1976 | | |
1977 | | - | |
1978 | | - | |
1979 | | - | |
1980 | | - | |
| 1977 | + | |
| 1978 | + | |
1981 | 1979 | | |
1982 | 1980 | | |
1983 | 1981 | | |
| |||
1988 | 1986 | | |
1989 | 1987 | | |
1990 | 1988 | | |
| 1989 | + | |
| 1990 | + | |
| 1991 | + | |
| 1992 | + | |
| 1993 | + | |
| 1994 | + | |
| 1995 | + | |
| 1996 | + | |
| 1997 | + | |
| 1998 | + | |
| 1999 | + | |
1991 | 2000 | | |
1992 | 2001 | | |
1993 | 2002 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
663 | 663 | | |
664 | 664 | | |
665 | 665 | | |
666 | | - | |
667 | | - | |
668 | | - | |
669 | | - | |
| 666 | + | |
| 667 | + | |
670 | 668 | | |
671 | 669 | | |
672 | 670 | | |
| |||
677 | 675 | | |
678 | 676 | | |
679 | 677 | | |
680 | | - | |
681 | | - | |
682 | | - | |
| 678 | + | |
683 | 679 | | |
684 | 680 | | |
685 | 681 | | |
| |||
0 commit comments