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.
Paths
| Differential D67135
[clang-tidy] performance-inefficient-vector-operation: Support proto repeated field ClosedPublic Authored by congliu on Sep 3 2019, 4:41 PM.
Details
Summary 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.
lebedev.ri retitled this revision from Support proto repeated field in performence-inefficient-vector-operation to [clang-tidy] performance-inefficient-vector-operation: Support proto repeated field.Sep 4 2019, 2:19 AM 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.
congliu marked 7 inline comments as done. Comment ActionsAddressed Haojian's comments.
Comment Actions thanks, looks good.
This revision is now accepted and ready to land.Sep 11 2019, 1:11 AM Closed by commit rL371963: [clang-tidy] performance-inefficient-vector-operation: Support proto repeated… (authored by hokein). · Explain WhySep 16 2019, 1:52 AM This revision was automatically updated to reflect the committed changes. 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.
Revision Contents
Diff 219988 clang-tools-extra/clang-tidy/performance/InefficientVectorOperationCheck.h
clang-tools-extra/clang-tidy/performance/InefficientVectorOperationCheck.cpp
clang-tools-extra/docs/clang-tidy/checks/performance-inefficient-vector-operation.rst
clang-tools-extra/test/clang-tidy/performance-inefficient-vector-operation.cpp
|
the include (probably added by clangd) is for google internal style, I believe you are developing at google internal codebase (rather than the opensource LLVM codebase)?