Bug 389056 - suggest using initializer lists
Summary: suggest using initializer lists
Status: CONFIRMED
Alias: None
Product: clazy
Classification: Developer tools
Component: general (show other bugs)
Version: unspecified
Platform: Other Linux
: NOR wishlist
Target Milestone: ---
Assignee: Unassigned bugs mailing-list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-01-16 14:22 UTC by Milian Wolff
Modified: 2018-03-24 12:21 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Milian Wolff 2018-01-16 14:22:04 UTC
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) { ... }
}
```
Comment 1 Sergio Martins 2018-03-24 12:21:23 UTC
Should be easy, this one