util/ForeignFifoBuffer: use Read() in MoveBuffer() and Shift()
This commit is contained in:
parent
849c4012c0
commit
8a3b48754e
|
@ -97,9 +97,10 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
void MoveBuffer(T *new_data, size_type new_capacity) noexcept {
|
void MoveBuffer(T *new_data, size_type new_capacity) noexcept {
|
||||||
assert(new_capacity >= tail - head);
|
const auto r = Read();
|
||||||
|
assert(new_capacity >= r.size());
|
||||||
|
std::move(r.begin(), r.end(), new_data);
|
||||||
|
|
||||||
std::move(data + head, data + tail, new_data);
|
|
||||||
data = new_data;
|
data = new_data;
|
||||||
capacity = new_capacity;
|
capacity = new_capacity;
|
||||||
tail -= head;
|
tail -= head;
|
||||||
|
@ -231,7 +232,8 @@ protected:
|
||||||
assert(tail <= capacity);
|
assert(tail <= capacity);
|
||||||
assert(tail >= head);
|
assert(tail >= head);
|
||||||
|
|
||||||
std::move(data + head, data + tail, data);
|
const auto r = Read();
|
||||||
|
std::move(r.begin(), r.end(), data);
|
||||||
|
|
||||||
tail -= head;
|
tail -= head;
|
||||||
head = 0;
|
head = 0;
|
||||||
|
|
Loading…
Reference in New Issue