Credence.Rule.AvoidGraphemesEnumCount
(credence v0.2.0)
Copy Markdown
Performance rule: warns when String.graphemes/1 |> Enum.count() is used.
For
Enum.count/1(no predicate): suggestsString.length/1, which avoids allocating an intermediate list of graphemes.For
Enum.count/2(with a predicate): suggests manual binary recursion over the string, which avoids allocating the intermediate grapheme list entirely.