Skip to content

Commit c23f106

Browse files
committed
refactor useless copy to const reference.
1 parent 0a6ae83 commit c23f106

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

src/types/redis_tdigest.cc

+3-3
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ namespace redis {
4949
// It should be replaced by a iteration of the rocksdb iterator
5050
class DummyCentroids {
5151
public:
52-
DummyCentroids(const TDigestMetadata& meta_data, std::vector<Centroid> centroids)
53-
: meta_data_(meta_data), centroids_(std::move(centroids)) {}
52+
DummyCentroids(const TDigestMetadata& meta_data, const std::vector<Centroid>& centroids)
53+
: meta_data_(meta_data), centroids_(centroids) {}
5454
class Iterator {
5555
public:
5656
Iterator(std::vector<Centroid>::const_iterator&& iter, const std::vector<Centroid>& centroids)
@@ -98,7 +98,7 @@ class DummyCentroids {
9898

9999
private:
100100
const TDigestMetadata& meta_data_;
101-
std::vector<Centroid> centroids_;
101+
const std::vector<Centroid>& centroids_;
102102
};
103103

104104
uint64_t constexpr kMaxElements = 1 * 1024; // 1k doubles

src/types/tdigest.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ struct Centroid {
3838

3939
std::string ToString() const { return fmt::format("centroid<mean: {}, weight: {}>", mean, weight); }
4040

41-
template <typename T>
42-
explicit Centroid(T&& centroid) : mean(centroid.mean), weight(centroid.weight) {}
41+
Centroid(const Centroid& centroid) = default;
4342

4443
explicit Centroid() = default;
4544
explicit Centroid(double mean, double weight) : mean(mean), weight(weight) {}

0 commit comments

Comments
 (0)