diff --git a/.clang-tidy b/.clang-tidy index 8e99fcc1701..322c6e58a68 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -1,7 +1,7 @@ # refer to https://clang.llvm.org/extra/clang-tidy/checks/list.html Checks: -*, clang-analyzer-core.*, clang-analyzer-cplusplus.*, clang-analyzer-deadcode.*, clang-analyzer-nullability.*, clang-analyzer-security.*, clang-analyzer-unix.*, clang-analyzer-valist.*, cppcoreguidelines-init-variables, cppcoreguidelines-macro-usage, cppcoreguidelines-interfaces-global-init, cppcoreguidelines-narrowing-conversions, cppcoreguidelines-no-malloc, cppcoreguidelines-prefer-member-initializer, cppcoreguidelines-special-member-functions, cppcoreguidelines-slicing, google-build-explicit-make-pair, google-default-arguments, google-explicit-constructor, modernize-avoid-bind, modernize-loop-convert, modernize-macro-to-enum, modernize-make-shared, modernize-make-unique, modernize-pass-by-value, modernize-redundant-void-arg, modernize-return-braced-init-list, modernize-use-auto, modernize-use-bool-literals, modernize-use-emplace, modernize-use-equals-default, modernize-use-equals-delete, modernize-use-nullptr, modernize-use-override, modernize-use-using, performance-faster-string-find, performance-for-range-copy, performance-implicit-conversion-in-loop, performance-inefficient-algorithm, performance-inefficient-vector-operation, performance-move-const-arg, performance-move-constructor-init, performance-no-automatic-move, performance-trivially-destructible, performance-type-promotion-in-math-fn, performance-unnecessary-copy-initialization, performance-unnecessary-value-param -WarningsAsErrors: clang-analyzer-*, -clang-analyzer-security.insecureAPI.rand, cppcoreguidelines-interfaces-global-init, cppcoreguidelines-no-malloc, cppcoreguidelines-slicing, google-*, modernize-use-emplace, modernize-use-equals-default, modernize-use-equals-delete, performance-implicit-conversion-in-loop, performance-inefficient-algorithm, performance-move-constructor-init, performance-no-automatic-move, performance-trivially-destructible, performance-type-promotion-in-math-fn, performance-unnecessary-copy-initialization, modernize-use-bool-literals, performance-unnecessary-value-param, modernize-make-unique, performance-for-range-copy, performance-faster-string-find, modernize-redundant-void-arg, modernize-avoid-bind, modernize-use-auto, modernize-use-using +WarningsAsErrors: clang-analyzer-*, -clang-analyzer-security.insecureAPI.rand, cppcoreguidelines-interfaces-global-init, cppcoreguidelines-no-malloc, cppcoreguidelines-slicing, google-*, modernize-use-emplace, modernize-use-equals-default, modernize-use-equals-delete, performance-implicit-conversion-in-loop, performance-inefficient-algorithm, performance-move-constructor-init, performance-no-automatic-move, performance-trivially-destructible, performance-type-promotion-in-math-fn, performance-unnecessary-copy-initialization, modernize-use-bool-literals, performance-unnecessary-value-param, modernize-make-unique, performance-for-range-copy, performance-faster-string-find, modernize-redundant-void-arg, modernize-avoid-bind, modernize-use-auto, modernize-use-using, performance-inefficient-vector-operation CheckOptions: - key: cppcoreguidelines-special-member-functions.AllowSoleDefaultDtor diff --git a/src/commands/redis_cmd.cc b/src/commands/redis_cmd.cc index c79229c1db0..aaa41336163 100644 --- a/src/commands/redis_cmd.cc +++ b/src/commands/redis_cmd.cc @@ -1458,6 +1458,7 @@ class CommandHKeys : public Commander { return Status(Status::RedisExecErr, s.ToString()); } std::vector keys; + keys.reserve(field_values.size()); for (const auto &fv : field_values) { keys.emplace_back(fv.field); } @@ -1476,6 +1477,7 @@ class CommandHVals : public Commander { return Status(Status::RedisExecErr, s.ToString()); } std::vector values; + values.reserve(field_values.size()); for (const auto &p : field_values) { values.emplace_back(p.value); } @@ -4277,6 +4279,7 @@ class CommandCommand : public Commander { return Status::OK(); } std::vector keys; + keys.reserve(keys_indexes.size()); for (const auto &key_index : keys_indexes) { keys.emplace_back(args_[key_index + 2]); } @@ -4560,6 +4563,7 @@ class CommandZScan : public CommandSubkeyScanBase { return Status(Status::RedisExecErr, s.ToString()); } std::vector score_strings; + score_strings.reserve(scores.size()); for (const auto &score : scores) { score_strings.emplace_back(Util::Float2String(score)); } diff --git a/src/types/redis_string.cc b/src/types/redis_string.cc index eefb766af97..aaffdfb57f0 100644 --- a/src/types/redis_string.cc +++ b/src/types/redis_string.cc @@ -398,6 +398,7 @@ rocksdb::Status String::MSetNX(const std::vector &pairs, int ttl, in int exists; std::vector keys; + keys.reserve(pairs.size()); for (StringPair pair : pairs) { keys.emplace_back(pair.key); } diff --git a/src/types/redis_zset.cc b/src/types/redis_zset.cc index e4c8eb44d71..8cffa19ec04 100644 --- a/src/types/redis_zset.cc +++ b/src/types/redis_zset.cc @@ -751,6 +751,7 @@ rocksdb::Status ZSet::UnionStore(const Slice &dst, const std::vector } if (!dst_zset.empty()) { std::vector mscores; + mscores.reserve(dst_zset.size()); for (const auto &iter : dst_zset) { mscores.emplace_back(MemberScore{iter.first, iter.second}); }