This is an archive of the discontinued LLVM Phabricator instance.

Replace size method call of containers to empty method where appropriate
ClosedPublic

Authored by xazax.hun on Jan 12 2015, 5:07 AM.

Details

Summary

This patch was generated by a clang tidy checker that is being open sourced.
The documentation of that checker is the following:

/ The emptiness of a container should be checked using the empty method
/ instead of the size method. It is not guaranteed that size is a
/ constant-time function, and it is generally more efficient and also shows
/ clearer intent to use empty. Furthermore some containers may implement the
/ empty method but not implement the size method. Using empty whenever
/ possible makes it easier to switch to another container in the future.

Diff Detail

Event Timeline

xazax.hun updated this revision to Diff 18015.Jan 12 2015, 5:07 AM
xazax.hun retitled this revision from to Replace size method call of containers to empty method where appropriate.
xazax.hun updated this object.
xazax.hun edited the test plan for this revision. (Show Details)
xazax.hun added reviewers: klimek, alexfh.
xazax.hun added a subscriber: Unknown Object (MLST).
alexfh edited edge metadata.Jan 12 2015, 5:20 AM

The patch looks good, but it would be nice to get an approval from the actual code owners.

dblaikie accepted this revision.Jan 12 2015, 12:54 PM
dblaikie added a reviewer: dblaikie.
dblaikie added a subscriber: dblaikie.

This looks reasonable enough that I'm willing to sign off on it. We can do anything further in post-commit review.

This revision is now accepted and ready to land.Jan 12 2015, 12:54 PM

Gábor, do you have commit rights or you need someone to land the patch for you?

I need someone to commit this.

Thanks,
Gábor

alexfh closed this revision.Jan 15 2015, 3:43 AM

Committed revision 226161.

Thanks for the patch!