Commit 0119b44
committed
Auto merge of #47772 - arthurprs:iter-position-bounds-check, r=dtolnay
Use the slice length to hint the optimizer about iter.position result
Using the len of the iterator doesn't give the same result.
That's also why we can't generalize it to all TrustedLen iterators.
Problem demo: https://godbolt.org/g/MXg2ae
Fix demo: https://godbolt.org/g/P8q5aZ
Second attempt of #47333
Third attempt of #45501
Fixes #459641 file changed
+4
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1245 | 1245 | | |
1246 | 1246 | | |
1247 | 1247 | | |
1248 | | - | |
| 1248 | + | |
| 1249 | + | |
1249 | 1250 | | |
1250 | 1251 | | |
1251 | 1252 | | |
| |||
1263 | 1264 | | |
1264 | 1265 | | |
1265 | 1266 | | |
1266 | | - | |
| 1267 | + | |
| 1268 | + | |
1267 | 1269 | | |
1268 | 1270 | | |
1269 | 1271 | | |
| |||
0 commit comments