diff --git a/.clang-tidy b/.clang-tidy index 0de4398ce5..a6b83c9af0 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -20,7 +20,7 @@ Checks: > -*, clang-diagnostic-*, -clang-diagnostic-error, clang-analyzer-*, -clang-analyzer-alpha*, google-*, -google-runtime-references, -google-readability-todo, - modernize-*, -modernize-use-trailing-return-type, + modernize-*, -modernize-use-trailing-return-type, -modernize-use-nodiscard, performance-*, bugprone-bool-pointer-implicit-conversion, bugprone-branch-clone, diff --git a/internal/core/src/index/VectorDiskIndex.cpp b/internal/core/src/index/VectorDiskIndex.cpp index 954fc0abd4..e80badcb65 100644 --- a/internal/core/src/index/VectorDiskIndex.cpp +++ b/internal/core/src/index/VectorDiskIndex.cpp @@ -216,7 +216,7 @@ VectorDiskAnnIndex::Query(const DatasetPtr dataset, if (round_decimal != -1) { const float multiplier = pow(10.0, round_decimal); for (int i = 0; i < total_num; i++) { - distances[i] = round(distances[i] * multiplier) / multiplier; + distances[i] = std::round(distances[i] * multiplier) / multiplier; } } auto result = std::make_unique(); diff --git a/internal/core/src/index/VectorMemIndex.cpp b/internal/core/src/index/VectorMemIndex.cpp index d00144927b..373e5cda45 100644 --- a/internal/core/src/index/VectorMemIndex.cpp +++ b/internal/core/src/index/VectorMemIndex.cpp @@ -15,6 +15,8 @@ // limitations under the License. #include "index/VectorMemIndex.h" + +#include #include "index/Meta.h" #include "index/Utils.h" #include "exceptions/EasyAssert.h" @@ -129,7 +131,7 @@ VectorMemIndex::Query(const DatasetPtr dataset, if (round_decimal != -1) { const float multiplier = pow(10.0, round_decimal); for (int i = 0; i < total_num; i++) { - distances[i] = round(distances[i] * multiplier) / multiplier; + distances[i] = std::round(distances[i] * multiplier) / multiplier; } } auto result = std::make_unique(); diff --git a/internal/core/src/query/SearchOnSealed.cpp b/internal/core/src/query/SearchOnSealed.cpp index 6cab86370d..adc4001809 100644 --- a/internal/core/src/query/SearchOnSealed.cpp +++ b/internal/core/src/query/SearchOnSealed.cpp @@ -58,7 +58,7 @@ SearchOnSealedIndex(const Schema& schema, if (round_decimal != -1) { const float multiplier = pow(10.0, round_decimal); for (int i = 0; i < total_num; i++) { - distances[i] = round(distances[i] * multiplier) / multiplier; + distances[i] = std::round(distances[i] * multiplier) / multiplier; } } result.seg_offsets_.resize(total_num); diff --git a/internal/core/src/query/SubSearchResult.cpp b/internal/core/src/query/SubSearchResult.cpp index 052c5b30ec..e25b1090ff 100644 --- a/internal/core/src/query/SubSearchResult.cpp +++ b/internal/core/src/query/SubSearchResult.cpp @@ -89,9 +89,8 @@ SubSearchResult::round_values() { if (round_decimal_ == -1) return; const float multiplier = pow(10.0, round_decimal_); - for (auto it = this->distances_.begin(); it != this->distances_.end(); - it++) { - *it = round(*it * multiplier) / multiplier; + for (float& distance : this->distances_) { + distance = std::round(distance * multiplier) / multiplier; } } diff --git a/internal/core/src/query/SubSearchResult.h b/internal/core/src/query/SubSearchResult.h index db7f41f933..87ca078225 100644 --- a/internal/core/src/query/SubSearchResult.h +++ b/internal/core/src/query/SubSearchResult.h @@ -34,11 +34,11 @@ class SubSearchResult { distances_(num_queries * topk, init_value(metric_type)) { } - SubSearchResult(SubSearchResult&& other) + SubSearchResult(SubSearchResult&& other) noexcept : num_queries_(other.num_queries_), topk_(other.topk_), round_decimal_(other.round_decimal_), - metric_type_(other.metric_type_), + metric_type_(std::move(other.metric_type_)), seg_offsets_(std::move(other.seg_offsets_)), distances_(std::move(other.distances_)) { } diff --git a/internal/core/src/segcore/ReduceStructure.h b/internal/core/src/segcore/ReduceStructure.h index c5ee7cb527..96956f006f 100644 --- a/internal/core/src/segcore/ReduceStructure.h +++ b/internal/core/src/segcore/ReduceStructure.h @@ -12,6 +12,7 @@ #pragma once #include +#include #include "common/Consts.h" #include "common/Types.h" @@ -33,7 +34,7 @@ struct SearchResultPair { int64_t index, int64_t lb, int64_t rb) - : primary_key_(primary_key), + : primary_key_(std::move(primary_key)), distance_(distance), search_result_(result), segment_index_(index), @@ -43,7 +44,7 @@ struct SearchResultPair { bool operator>(const SearchResultPair& other) const { - if (fabs(distance_ - other.distance_) < 0.000001f) { + if (std::fabs(distance_ - other.distance_) < 0.000001f) { return primary_key_ < other.primary_key_; } return distance_ > other.distance_;