Bug 354138 - new check: Warn when using functions calls in for condition
Summary: new check: Warn when using functions calls in for condition
Status: RESOLVED NOT A BUG
Alias: None
Product: clazy
Classification: Developer tools
Component: general (other bugs)
Version First Reported In: unspecified
Platform: Other Linux
: NOR wishlist
Target Milestone: ---
Assignee: Unassigned bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-10-20 18:17 UTC by Sergio Martins
Modified: 2016-02-11 21:38 UTC (History)
0 users

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 Sergio Martins 2015-10-20 18:17:08 UTC
for (int i = 0; i < foo.count(); ++i)

It's generally faster to do:
int count = foo.count()
for (int i = 0; i < count; ++i)

Maybe we could have this check only for containers, and optionally for all functions, because sometimes there are expensive functions.
Comment 1 Sergio Martins 2016-02-11 21:38:43 UTC
out of scope, should probably go to clang-tidy