Skip to content

Commit ec2fb0c

Browse files
committed
DRYed constructor [skip ci]
1 parent a0bb20a commit ec2fb0c

File tree

1 file changed

+1
-10
lines changed

1 file changed

+1
-10
lines changed

include/pgvector/sparsevec.hpp

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,7 @@ class SparseVector {
2929
}
3030

3131
/// Creates a sparse vector from a dense vector.
32-
explicit SparseVector(const std::vector<float>& value) {
33-
dimensions_ = value.size();
34-
for (size_t i = 0; i < value.size(); i++) {
35-
float v = value[i];
36-
if (v != 0) {
37-
indices_.push_back(i);
38-
values_.push_back(v);
39-
}
40-
}
41-
}
32+
explicit SparseVector(const std::vector<float>& value) : SparseVector(std::span<const float>{value}) {}
4233

4334
/// Creates a sparse vector from a span.
4435
explicit SparseVector(std::span<const float> value) {

0 commit comments

Comments
 (0)