Bug 354138

Summary: new check: Warn when using functions calls in for condition
Product: [Developer tools] clazy Reporter: Sergio Martins <smartins>
Component: generalAssignee: Unassigned bugs <unassigned-bugs-null>
Status: RESOLVED NOT A BUG    
Severity: wishlist    
Priority: NOR    
Version First Reported In: unspecified   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

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