[base] Fix SmallVector's move constructor
The move constructor left the "other" (source) vector in an unpredictable state, depending on the size: For "big" small-vectors (using dynamically allocated storage) we would reset it to an empty vector. "Small" small-vectors on the other hand were not reset. Fix this to make it possible to reuse a SmallVector after moving its content to another SmallVector. This also flushes out a bug more easily, see https://crrev.com/c/4215292. R=dlehmann@chromium.org CC=thibaudm@chromium.org Change-Id: Ia188c3639e9104dfbeb589bfc49e3228f4cbeda7 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4215297 Reviewed-by: Daniel Lehmann <dlehmann@chromium.org> Commit-Queue: Clemens Backes <clemensb@chromium.org> Cr-Commit-Position: refs/heads/main@{#85612}
This commit is contained in:
parent
e0790d35d1
commit
8dfd2ce708
@ -81,13 +81,13 @@ class SmallVector {
|
||||
begin_ = other.begin_;
|
||||
end_ = other.end_;
|
||||
end_of_storage_ = other.end_of_storage_;
|
||||
other.reset_to_inline_storage();
|
||||
} else {
|
||||
DCHECK_GE(capacity(), other.size()); // Sanity check.
|
||||
size_t other_size = other.size();
|
||||
memcpy(begin_, other.begin_, sizeof(T) * other_size);
|
||||
end_ = begin_ + other_size;
|
||||
}
|
||||
other.reset_to_inline_storage();
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user