Skip to content

Commit

Permalink
cylondata#610: correctly use reserve in vector to prevent reallocatio…
Browse files Browse the repository at this point in the history
…ns and remove the incorrect initialization in the constructor.
  • Loading branch information
mstaylor committed Sep 11, 2022
1 parent 796fd58 commit 748afd1
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion cpp/src/cylon/util/arrow_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,8 @@ arrow::Status SampleArray(const std::shared_ptr<arrow::ChunkedArray> &arr,
static std::mt19937_64 gen(rd());
std::uniform_int_distribution<int64_t> distrib(0, arr->length() - 1);

std::vector<int64_t> vector_indices(num_samples);
std::vector<int64_t> vector_indices;
vector_indices.reserve(num_samples);

for (uint64_t i = 0; i < num_samples; i++) {
vector_indices.push_back(distrib(gen));
Expand Down

0 comments on commit 748afd1

Please sign in to comment.