diff options
author | Ian Rogers <irogers@google.com> | 2014-10-08 17:27:48 -0700 |
---|---|---|
committer | Ian Rogers <irogers@google.com> | 2014-10-09 08:25:34 -0700 |
commit | 0279ebb3efd653e6bb255470c99d26949c7bcd95 (patch) | |
tree | d58b29754f7b3c88616e6e4d6c19346821d244ae /compiler/vector_output_stream.h | |
parent | f1f05d303988a5c071c87b760056be8358276c94 (diff) | |
download | android_art-0279ebb3efd653e6bb255470c99d26949c7bcd95.tar.gz android_art-0279ebb3efd653e6bb255470c99d26949c7bcd95.tar.bz2 android_art-0279ebb3efd653e6bb255470c99d26949c7bcd95.zip |
Tidy ELF builder.
Don't do "if (ptr)". Use const. Use DISALLOW_COPY_AND_ASSIGN. Avoid public
member variables.
Move ValueObject to base and use in ELF builder.
Tidy VectorOutputStream to not use non-const reference arguments.
Change-Id: I2c727c3fc61769c3726de7cfb68b2d6eb4477e53
Diffstat (limited to 'compiler/vector_output_stream.h')
-rw-r--r-- | compiler/vector_output_stream.h | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/compiler/vector_output_stream.h b/compiler/vector_output_stream.h index 09daa12e02..3c5877c0bd 100644 --- a/compiler/vector_output_stream.h +++ b/compiler/vector_output_stream.h @@ -25,21 +25,21 @@ namespace art { -class VectorOutputStream : public OutputStream { +class VectorOutputStream FINAL : public OutputStream { public: - VectorOutputStream(const std::string& location, std::vector<uint8_t>& vector); + VectorOutputStream(const std::string& location, std::vector<uint8_t>* vector); virtual ~VectorOutputStream() {} bool WriteFully(const void* buffer, size_t byte_count) { - if (static_cast<size_t>(offset_) == vector_.size()) { + if (static_cast<size_t>(offset_) == vector_->size()) { const uint8_t* start = reinterpret_cast<const uint8_t*>(buffer); - vector_.insert(vector_.end(), &start[0], &start[byte_count]); + vector_->insert(vector_->end(), &start[0], &start[byte_count]); offset_ += byte_count; } else { off_t new_offset = offset_ + byte_count; EnsureCapacity(new_offset); - memcpy(&vector_[offset_], buffer, byte_count); + memcpy(&(*vector_)[offset_], buffer, byte_count); offset_ = new_offset; } return true; @@ -49,13 +49,13 @@ class VectorOutputStream : public OutputStream { private: void EnsureCapacity(off_t new_offset) { - if (new_offset > static_cast<off_t>(vector_.size())) { - vector_.resize(new_offset); + if (new_offset > static_cast<off_t>(vector_->size())) { + vector_->resize(new_offset); } } off_t offset_; - std::vector<uint8_t>& vector_; + std::vector<uint8_t>* const vector_; DISALLOW_COPY_AND_ASSIGN(VectorOutputStream); }; |