Skip to content

Commit

Permalink
layers: Optimize small_vector constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
nrmu9 committed Mar 6, 2025
1 parent 3ea34d9 commit de9221f
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions layers/containers/custom_containers.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,13 +160,14 @@ class small_vector {
}

small_vector(size_type size, const value_type &value = value_type()) : size_(0), capacity_(N), working_store_(GetSmallStore()) {
reserve(size);
auto dest = GetWorkingStore();
for (size_type i = 0; i < size; i++) {
new (dest) value_type(value);
++dest;
if (size > 0) {
reserve(size);
auto dest = GetWorkingStore();
for (size_type i = 0; i < size; i++) {
new (&dest[i]) value_type(value);
}
size_ = size;
}
size_ = size;
}

~small_vector() { clear(); }
Expand Down

0 comments on commit de9221f

Please sign in to comment.