-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
L-perfLint: Belongs in the perf lint groupLint: Belongs in the perf lint group
Description
For str::starts_with using a single char string literal generates much better code as it can just compare the single byte of the str literal, while comparing against a char involves decoding possibly multiple bytes of the text. Here is the Godbolt for it: https://rust.godbolt.org/z/V_Arel
Therefore the single_char_pattern lint should not apply for str::starts_with (and possibly ends_with) and instead it should possibly even advice against using a char.
clippy 0.0.212 (b2601be 2018-11-27)
Metadata
Metadata
Assignees
Labels
L-perfLint: Belongs in the perf lint groupLint: Belongs in the perf lint group