Bug 389056

Summary: suggest using initializer lists
Product: [Developer tools] clazy Reporter: Milian Wolff <mail>
Component: generalAssignee: 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 In:
Sentry Crash Report:

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