diff options
author | 2017-09-28 13:50:37 +0100 | |
---|---|---|
committer | 2017-09-28 14:06:53 +0100 | |
commit | d7559b7b9da5ee839b8f21fc8d6e3e9ae5c573f7 (patch) | |
tree | f8cabe1440bd9910932ea73a1df7a35be343f909 /runtime/dex_instruction_iterator.h | |
parent | 6e7e0ddf1dda35570cd9ed23751d9306f7353d7f (diff) |
Clean up DexInstuctionIterator.
Follow-up to
https://android-review.googlesource.com/493297 .
Test: m test-art-host-gtest
Test: testrunner.py --host
Bug: 63756964
Change-Id: I454a748858e54f7ddfc54f631d7cd97d63557aff
Diffstat (limited to 'runtime/dex_instruction_iterator.h')
-rw-r--r-- | runtime/dex_instruction_iterator.h | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/runtime/dex_instruction_iterator.h b/runtime/dex_instruction_iterator.h index 6585875df4..280746e9dc 100644 --- a/runtime/dex_instruction_iterator.h +++ b/runtime/dex_instruction_iterator.h @@ -26,8 +26,8 @@ namespace art { class DexInstructionIterator : public std::iterator<std::forward_iterator_tag, Instruction> { public: - using Type = std::iterator<std::forward_iterator_tag, Instruction>::value_type; - using difference_type = typename std::iterator<std::forward_iterator_tag, Type>::difference_type; + using value_type = std::iterator<std::forward_iterator_tag, Instruction>::value_type; + using difference_type = std::iterator<std::forward_iterator_tag, value_type>::difference_type; DexInstructionIterator() = default; DexInstructionIterator(const DexInstructionIterator&) = default; @@ -35,12 +35,8 @@ class DexInstructionIterator : public std::iterator<std::forward_iterator_tag, I DexInstructionIterator& operator=(const DexInstructionIterator&) = default; DexInstructionIterator& operator=(DexInstructionIterator&&) = default; - explicit DexInstructionIterator(const Type* inst) : inst_(inst) {} - explicit DexInstructionIterator(const uint16_t* inst) : inst_(Type::At(inst)) {} - - ALWAYS_INLINE bool operator==(const DexInstructionIterator& other) const { - return inst_ == other.inst_ || inst_ == nullptr || other.inst_ == nullptr; - } + explicit DexInstructionIterator(const value_type* inst) : inst_(inst) {} + explicit DexInstructionIterator(const uint16_t* inst) : inst_(value_type::At(inst)) {} // Value after modification. DexInstructionIterator& operator++() { @@ -55,11 +51,11 @@ class DexInstructionIterator : public std::iterator<std::forward_iterator_tag, I return temp; } - const Type& operator*() const { + const value_type& operator*() const { return *inst_; } - const Type* operator->() const { + const value_type* operator->() const { return &**this; } @@ -69,14 +65,19 @@ class DexInstructionIterator : public std::iterator<std::forward_iterator_tag, I reinterpret_cast<const uint16_t*>(code_item_begin.inst_); } - const Type* Inst() const { + const value_type* Inst() const { return inst_; } private: - const Type* inst_ = nullptr; + const value_type* inst_ = nullptr; }; +static ALWAYS_INLINE inline bool operator==(const DexInstructionIterator& lhs, + const DexInstructionIterator& rhs) { + return lhs.Inst() == rhs.Inst(); +} + static inline bool operator!=(const DexInstructionIterator& lhs, const DexInstructionIterator& rhs) { return !(lhs == rhs); |