diff options
author | Alexander Kornienko <alexfh@google.com> | 2015-01-23 15:10:37 +0000 |
---|---|---|
committer | Alexander Kornienko <alexfh@google.com> | 2015-01-23 15:10:37 +0000 |
commit | e94b7c24c809dd398a146786e9612afa99ed0395 (patch) | |
tree | 953cf3c54c9b64a40e2a925628eefb4072ad9a25 /clang-tools-extra/clang-tidy/readability/ReadabilityTidyModule.cpp | |
parent | a6354cae566699786f3755d684504e14518811e7 (diff) | |
download | bcm5719-llvm-e94b7c24c809dd398a146786e9612afa99ed0395.tar.gz bcm5719-llvm-e94b7c24c809dd398a146786e9612afa99ed0395.zip |
[clang-tidy] Use shrink_to_fit instead of copy and swap trick
The shrink_to_fit() method is more readable and more effective than
the copy and swap trick to reduce the capacity of a shrinkable container.
Note that, the shrink_to_fit() method is only available in C++11 and up.
Example:
std::vector<int>(v).swap(v); will be replaced with v.shrink_to_fit();
http://reviews.llvm.org/D7087
Patch by Gábor Horváth!
llvm-svn: 226912
Diffstat (limited to 'clang-tools-extra/clang-tidy/readability/ReadabilityTidyModule.cpp')
-rw-r--r-- | clang-tools-extra/clang-tidy/readability/ReadabilityTidyModule.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/clang-tools-extra/clang-tidy/readability/ReadabilityTidyModule.cpp b/clang-tools-extra/clang-tidy/readability/ReadabilityTidyModule.cpp index 315912b128b..a92f8a4313d 100644 --- a/clang-tools-extra/clang-tidy/readability/ReadabilityTidyModule.cpp +++ b/clang-tools-extra/clang-tidy/readability/ReadabilityTidyModule.cpp @@ -15,6 +15,7 @@ #include "ElseAfterReturnCheck.h" #include "FunctionSize.h" #include "RedundantSmartptrGet.h" +#include "ShrinkToFitCheck.h" namespace clang { namespace tidy { @@ -33,6 +34,8 @@ public: "readability-function-size"); CheckFactories.registerCheck<RedundantSmartptrGet>( "readability-redundant-smartptr-get"); + CheckFactories.registerCheck<ShrinkToFitCheck>( + "readability-shrink-to-fit"); } }; |