Skip to content

Commit

Permalink
enhance: reserve vector space to reduce reallocate cost in Views() an…
Browse files Browse the repository at this point in the history
…d StringViews() (#37182)

issue: #37152

Signed-off-by: chasingegg <[email protected]>
  • Loading branch information
chasingegg authored Oct 31, 2024
1 parent 6e37372 commit 2092dc0
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions internal/core/src/mmap/Column.h
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,7 @@ class SingleChunkVariableColumn : public SingleChunkColumnBase {
std::pair<std::vector<std::string_view>, FixedVector<bool>>
StringViews() const override {
std::vector<std::string_view> res;
res.reserve(num_rows_);
char* pos = data_;
for (size_t i = 0; i < num_rows_; ++i) {
uint32_t size;
Expand All @@ -696,6 +697,7 @@ class SingleChunkVariableColumn : public SingleChunkColumnBase {
[[nodiscard]] std::vector<ViewType>
Views() const {
std::vector<ViewType> res;
res.reserve(num_rows_);
char* pos = data_;
for (size_t i = 0; i < num_rows_; ++i) {
uint32_t size;
Expand Down

0 comments on commit 2092dc0

Please sign in to comment.