Finds calls that add element to protobuf repeated field in a loop without calling Reserve() before the loop. Calling Reserve() first can avoid unnecessary memory reallocations.
A new option EnableProto is added to guard this feature.
Differential D67135
[clang-tidy] performance-inefficient-vector-operation: Support proto repeated field congliu on Sep 3 2019, 4:41 PM. Authored by
Details
Finds calls that add element to protobuf repeated field in a loop without calling Reserve() before the loop. Calling Reserve() first can avoid unnecessary memory reallocations. A new option EnableProto is added to guard this feature.
Diff Detail Event TimelineComment Actions Please mention new option in Release Notes.
Comment Actions I'm not sure this is the correct approach. Comment Actions Could you elaborate how the parameterized check will look like? By config did you mean the check options? Comment Actions your patch doesn't have a full context, please upload the patch with full context (=U99999) or use Arcanist.
The AST for protobuf is quite different compared with normal vector, so I don't think there will be an easy and simple way to do it in a config way.
Comment Actions Addressed Haojian's comments.
Comment Actions thanks, looks good.
Comment Actions Committed in rL371963, just curious why you failed to commit? if you are using llvm git monorepo, ./llvm/utils/git-svn/git-llvm push should work. |
See other checks documentation as example of options descriptions.