Disallow copy and assign of EmbeddedVector
EmbeddedVector lives on the stack only, and should not be implicitly copied or assigned. This also removes remaining uses of the removed Vector::set_start method. R=sigurds@chromium.org Bug: v8:9142 Change-Id: I829e6ffad6b1a30baa6c874265e92d615dd0c981 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1578458 Reviewed-by: Sigurd Schneider <sigurds@chromium.org> Commit-Queue: Clemens Hammacher <clemensh@chromium.org> Cr-Commit-Position: refs/heads/master@{#60940}
This commit is contained in:
parent
99b8521cb1
commit
06d750b59c
22
src/vector.h
22
src/vector.h
@ -315,28 +315,14 @@ class EmbeddedVector : public Vector<T> {
|
||||
public:
|
||||
EmbeddedVector() : Vector<T>(buffer_, kSize) {}
|
||||
|
||||
explicit EmbeddedVector(T initial_value) : Vector<T>(buffer_, kSize) {
|
||||
for (int i = 0; i < kSize; ++i) {
|
||||
buffer_[i] = initial_value;
|
||||
}
|
||||
}
|
||||
|
||||
// When copying, make underlying Vector to reference our buffer.
|
||||
EmbeddedVector(const EmbeddedVector& rhs) V8_NOEXCEPT : Vector<T>(rhs) {
|
||||
MemCopy(buffer_, rhs.buffer_, sizeof(T) * kSize);
|
||||
this->set_start(buffer_);
|
||||
}
|
||||
|
||||
EmbeddedVector& operator=(const EmbeddedVector& rhs) V8_NOEXCEPT {
|
||||
if (this == &rhs) return *this;
|
||||
Vector<T>::operator=(rhs);
|
||||
MemCopy(buffer_, rhs.buffer_, sizeof(T) * kSize);
|
||||
this->set_start(buffer_);
|
||||
return *this;
|
||||
explicit EmbeddedVector(const T& initial_value) : Vector<T>(buffer_, kSize) {
|
||||
std::fill_n(buffer_, kSize, initial_value);
|
||||
}
|
||||
|
||||
private:
|
||||
T buffer_[kSize];
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(EmbeddedVector);
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
|
Loading…
Reference in New Issue
Block a user