Skip to content

Commit 61851c9

Browse files
committed
Added comments [skip ci]
1 parent 6bbe005 commit 61851c9

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

include/pgvector/sparsevec.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ class SparseVector {
2828
throw std::invalid_argument{"too many dimensions"};
2929
}
3030
dimensions_ = static_cast<int>(value.size());
31+
32+
// do not reserve capacity for indices/values since likely many zeros
3133
for (size_t i = 0; i < value.size(); i++) {
3234
float v = value[i];
3335
if (v != 0) {
@@ -44,6 +46,7 @@ class SparseVector {
4446
}
4547
dimensions_ = dimensions;
4648

49+
// could probably reserve capacity for indices since not expecting zeros
4750
for (const auto& [i, v] : map) {
4851
if (i < 0 || i >= dimensions) {
4952
throw std::invalid_argument{"sparsevec index out of bounds"};

0 commit comments

Comments
 (0)