| Summary: | suggest using initializer lists | ||
|---|---|---|---|
| Product: | [Developer tools] clazy | Reporter: | Milian Wolff <mail> |
| Component: | general | Assignee: | Unassigned bugs <unassigned-bugs-null> |
| Status: | CONFIRMED --- | ||
| Severity: | wishlist | CC: | smartins |
| Priority: | NOR | ||
| Version First Reported In: | unspecified | ||
| Target Milestone: | --- | ||
| Platform: | Other | ||
| OS: | Linux | ||
| Latest Commit: | Version Fixed/Implemented In: | ||
| Sentry Crash Report: | |||
Should be easy, this one |
I often come across code like this which is bad, from a performance POV: ``` QVector<Type> l1 = ...; QVector<Type> l2 = ...; foreach(const auto& item : l1 + l2) { ... } ``` Instead, it would be faster to use a lambda or a nested loop to get rid of the temporary allocation. E.g.: ``` QVector<Type> l1 = ...; QVector<Type> l2 = ...; for (const auto& list : {l1, l2}) { for (const auto& item : list) { ... } } ```