Skip to content

Commit

Permalink
use memcpy instead of elementwise vector copying
Browse files Browse the repository at this point in the history
  • Loading branch information
stas-sl committed Oct 3, 2024
1 parent 27a7a69 commit 63ad606
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion components/sound_level_meter/sound_level_meter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,11 @@ template<typename T> std::vector<T> &BufferPool<T>::current() { return this->buf
template<typename T> BufferPool<T> &BufferPool<T>::operator++(int) {
assert(this->index_ < this->max_depth_ - 1 && "Index out of bounds");
this->index_++;
this->buffers_[this->index_] = this->buffers_[this->index_ - 1];
auto &dst = this->buffers_[this->index_];
auto &src = this->buffers_[this->index_ - 1];
auto n = src.size();
dst.resize(n);
memcpy(&dst[0], &src[0], n * sizeof(T));
return *this;
}

Expand Down

0 comments on commit 63ad606

Please sign in to comment.