Skip to content

Slow suggestion of single_char_pattern #3813

Closed
@CryZe

Description

@CryZe

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

No one assigned

    Labels

    L-perfLint: Belongs in the perf lint group

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions