Slicing after str::starts_with
performs unnecessary checks
#72558
Labels
A-str
Area: str and String
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
C-optimization
Category: An issue highlighting optimization opportunities or PRs implementing such
I-slow
Issue: Problems and improvements with respect to performance of generated code.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Without unsafe (playground)
With unsafe (playground)
I'm not terribly familiar with assembly, but the compiler is clearly performing checks where they aren't necessary. Given the knowledge that the string starts with a literal (in this case two ASCII bytes), we should be able to slice without any additional performance costs.
The text was updated successfully, but these errors were encountered: