[base] Remove OwnedVector::start
For some reason, {OwnedVector} defines both a {start()} and a {begin()} accessor which return the same value. As {begin()} is the name that the standard library uses, this CL removes {start()} and switches all uses to {begin()}. R=mslekova@chromium.org Change-Id: Ib505fe146db396f7589404c5a630e19248624729 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4075865 Reviewed-by: Maya Lekova <mslekova@chromium.org> Commit-Queue: Clemens Backes <clemensb@chromium.org> Cr-Commit-Position: refs/heads/main@{#84643}
This commit is contained in:
parent
608c5d5ef3
commit
cd1a29a5d0
@ -235,14 +235,12 @@ class OwnedVector {
|
||||
// Returns whether or not the vector is empty.
|
||||
constexpr bool empty() const { return length_ == 0; }
|
||||
|
||||
// Returns the pointer to the start of the data in the vector.
|
||||
T* start() const {
|
||||
constexpr T* begin() const {
|
||||
DCHECK_IMPLIES(length_ > 0, data_ != nullptr);
|
||||
return data_.get();
|
||||
}
|
||||
|
||||
constexpr T* begin() const { return start(); }
|
||||
constexpr T* end() const { return start() + size(); }
|
||||
constexpr T* end() const { return begin() + length_; }
|
||||
|
||||
// Access individual vector elements - checks bounds in debug mode.
|
||||
T& operator[](size_t index) const {
|
||||
@ -251,7 +249,7 @@ class OwnedVector {
|
||||
}
|
||||
|
||||
// Returns a {Vector<T>} view of the data in this vector.
|
||||
Vector<T> as_vector() const { return Vector<T>(start(), size()); }
|
||||
Vector<T> as_vector() const { return {begin(), size()}; }
|
||||
|
||||
// Releases the backing data from this vector and transfers ownership to the
|
||||
// caller. This vector will be empty afterwards.
|
||||
@ -287,7 +285,7 @@ class OwnedVector {
|
||||
using non_const_t = typename std::remove_const<T>::type;
|
||||
auto vec =
|
||||
OwnedVector<non_const_t>::NewForOverwrite(std::distance(begin, end));
|
||||
std::copy(begin, end, vec.start());
|
||||
std::copy(begin, end, vec.begin());
|
||||
return vec;
|
||||
}
|
||||
|
||||
|
@ -102,11 +102,11 @@ class DefaultAssemblerBuffer : public AssemblerBuffer {
|
||||
: buffer_(base::OwnedVector<uint8_t>::NewForOverwrite(
|
||||
std::max(AssemblerBase::kMinimalBufferSize, size))) {
|
||||
#ifdef DEBUG
|
||||
ZapCode(reinterpret_cast<Address>(buffer_.start()), buffer_.size());
|
||||
ZapCode(reinterpret_cast<Address>(buffer_.begin()), buffer_.size());
|
||||
#endif
|
||||
}
|
||||
|
||||
byte* start() const override { return buffer_.start(); }
|
||||
byte* start() const override { return buffer_.begin(); }
|
||||
|
||||
int size() const override { return static_cast<int>(buffer_.size()); }
|
||||
|
||||
|
@ -58,12 +58,12 @@ class V8_EXPORT_PRIVATE AsyncStreamingDecoder : public StreamingDecoder {
|
||||
bytes_(base::OwnedVector<uint8_t>::NewForOverwrite(
|
||||
1 + length_bytes.length() + payload_length)),
|
||||
payload_offset_(1 + length_bytes.length()) {
|
||||
bytes_.start()[0] = id;
|
||||
memcpy(bytes_.start() + 1, &length_bytes.first(), length_bytes.length());
|
||||
bytes_.begin()[0] = id;
|
||||
memcpy(bytes_.begin() + 1, &length_bytes.first(), length_bytes.length());
|
||||
}
|
||||
|
||||
SectionCode section_code() const {
|
||||
return static_cast<SectionCode>(bytes_.start()[0]);
|
||||
return static_cast<SectionCode>(bytes_.begin()[0]);
|
||||
}
|
||||
|
||||
base::Vector<const uint8_t> GetCode(WireBytesRef ref) const final {
|
||||
|
@ -1072,7 +1072,7 @@ WasmCode* NativeModule::AddCodeForTesting(Handle<Code> code) {
|
||||
base::OwnedVector<byte> source_pos =
|
||||
base::OwnedVector<byte>::NewForOverwrite(source_pos_table->length());
|
||||
if (source_pos_table->length() > 0) {
|
||||
source_pos_table->copy_out(0, source_pos.start(),
|
||||
source_pos_table->copy_out(0, source_pos.begin(),
|
||||
source_pos_table->length());
|
||||
}
|
||||
CHECK(!code->is_off_heap_trampoline());
|
||||
|
@ -2036,7 +2036,7 @@ std::unique_ptr<char[]> WasmExportedFunction::GetDebugName(
|
||||
// prefix + parameters + delimiter + returns + zero byte
|
||||
size_t len = strlen(kPrefix) + sig->all().size() + 2;
|
||||
auto buffer = base::OwnedVector<char>::New(len);
|
||||
memcpy(buffer.start(), kPrefix, strlen(kPrefix));
|
||||
memcpy(buffer.begin(), kPrefix, strlen(kPrefix));
|
||||
PrintSignature(buffer.as_vector() + strlen(kPrefix), sig);
|
||||
return buffer.ReleaseData();
|
||||
}
|
||||
|
@ -273,13 +273,13 @@ uint32_t TestingModuleBuilder::AddBytes(base::Vector<const byte> bytes) {
|
||||
base::OwnedVector<uint8_t> new_bytes =
|
||||
base::OwnedVector<uint8_t>::New(new_size);
|
||||
if (old_size > 0) {
|
||||
memcpy(new_bytes.start(), old_bytes.begin(), old_size);
|
||||
memcpy(new_bytes.begin(), old_bytes.begin(), old_size);
|
||||
} else {
|
||||
// Set the unused byte. It is never decoded, but the bytes are used as the
|
||||
// key in the native module cache.
|
||||
new_bytes[0] = 0;
|
||||
}
|
||||
memcpy(new_bytes.start() + bytes_offset, bytes.begin(), bytes.length());
|
||||
memcpy(new_bytes.begin() + bytes_offset, bytes.begin(), bytes.length());
|
||||
native_module_->SetWireBytes(std::move(new_bytes));
|
||||
return bytes_offset;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user