Commit 2e0dad7
committed
Rollup merge of rust-lang#32456 - bluss:str-zero, r=alexcrichton
Hardcode accepting 0 as a valid str char boundary
If we check explicitly for index == 0, that removes the need to read the
byte at index 0, so it avoids a trip to the string's memory, and it
optimizes out the slicing index' bounds check whenever it is (a constant) zero.1 file changed
+5
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1953 | 1953 | | |
1954 | 1954 | | |
1955 | 1955 | | |
1956 | | - | |
| 1956 | + | |
| 1957 | + | |
| 1958 | + | |
| 1959 | + | |
1957 | 1960 | | |
1958 | 1961 | | |
1959 | 1962 | | |
| |||
2026 | 2029 | | |
2027 | 2030 | | |
2028 | 2031 | | |
| 2032 | + | |
2029 | 2033 | | |
2030 | 2034 | | |
2031 | 2035 | | |
| |||
0 commit comments