Commit 519efef5 authored by Sigurd Schneider's avatar Sigurd Schneider Committed by Commit Bot

[deoptimizer] Manage input index in TranslatedFrame::iterator

This manages input_index directly in TranslatedFrame::iterator.
I think the overhead is low enough, expecially since all uses
of the iterator, except one, compute input_index anyway.

Bug: v8:7679
Change-Id: I7e5fc08ff23a49415265afd617248c55f4d95e19
Reviewed-on: https://chromium-review.googlesource.com/1021711
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: 's avatarJaroslav Sevcik <jarin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#52739}
parent 25acc255
This diff is collapsed.
......@@ -171,17 +171,20 @@ class TranslatedFrame {
class iterator {
public:
iterator& operator++() {
++input_index_;
AdvanceIterator(&position_);
return *this;
}
iterator operator++(int) {
++input_index_;
iterator original(position_);
AdvanceIterator(&position_);
return original;
}
bool operator==(const iterator& other) const {
// Ignore {input_index_} for equality.
return position_ == other.position_;
}
bool operator!=(const iterator& other) const { return !(*this == other); }
......@@ -191,13 +194,16 @@ class TranslatedFrame {
const TranslatedValue& operator*() const { return (*position_); }
const TranslatedValue* operator->() const { return &(*position_); }
int input_index() const { return input_index_; }
private:
friend TranslatedFrame;
explicit iterator(std::deque<TranslatedValue>::iterator position)
: position_(position) {}
: position_(position), input_index_(0) {}
std::deque<TranslatedValue>::iterator position_;
int input_index_;
};
typedef TranslatedValue& reference;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment