Skip to content

Commit

Permalink
reduce usage of steady_vector::size_
Browse files Browse the repository at this point in the history
  • Loading branch information
lixinqi committed Jun 14, 2022
1 parent e7ae284 commit b2a808b
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions oneflow/core/common/steady_vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,13 @@ class SteadyVector {

void push_back(const T& elem) {
std::unique_lock<std::mutex> lock(mutex_);
int granularity = GetGranularity(size_);
if (size_ + 1 == (1 << granularity)) {
size_t size = size_;
int granularity = GetGranularity(size);
if (size + 1 == (1 << granularity)) {
CHECK_LT(granularity, N);
granularity2data_[granularity].reset(new T[1 << granularity]);
}
this->Mut(size_) = elem;
this->Mut(size) = elem;
++size_;
}

Expand Down

0 comments on commit b2a808b

Please sign in to comment.