-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Open
Labels
A-lintArea: New lintsArea: New lintsC-enhancementCategory: Enhancement of lints, like adding more cases or adding help messagesCategory: Enhancement of lints, like adding more cases or adding help messagesL-perfLint: Belongs in the perf lint groupLint: Belongs in the perf lint groupL-suggestionLint: Improving, adding or fixing lint suggestionsLint: Improving, adding or fixing lint suggestions
Description
There are some very slow ways of extending a vector with len
new elements:
vec.extend(&vec![elem; len]);
vec.extend_from_slice(&vec![elem; len]);
Instead it should be written like this:
vec.resize(vec.len() + len, elem);
This sounds like code that nobody would ever write, but it actually has real-world precedent: Frommi/miniz_oxide#55
Metadata
Metadata
Assignees
Labels
A-lintArea: New lintsArea: New lintsC-enhancementCategory: Enhancement of lints, like adding more cases or adding help messagesCategory: Enhancement of lints, like adding more cases or adding help messagesL-perfLint: Belongs in the perf lint groupLint: Belongs in the perf lint groupL-suggestionLint: Improving, adding or fixing lint suggestionsLint: Improving, adding or fixing lint suggestions