Commit 9a65c0ef authored by clemensh's avatar clemensh Committed by Commit bot

Refactoring: Avoid redundant checks in SingletonFor

SingletonFor(type, state) returns NULL and does nothing whenever SingletonFor(type) also return NULL. So checking this beforehand is redundant.

This is my first CL, so I also use it to get familiar with the system.

R=titzer@chromium.org
BUG=

Review URL: https://codereview.chromium.org/1862753003

Cr-Commit-Position: refs/heads/master@{#35285}
parent 260df721
......@@ -104,17 +104,15 @@ void StackFrameIterator::Reset(ThreadLocalTop* top) {
StackFrame::Type type = ExitFrame::GetStateForFramePointer(
Isolate::c_entry_fp(top), &state);
handler_ = StackHandler::FromAddress(Isolate::handler(top));
if (SingletonFor(type) == NULL) return;
frame_ = SingletonFor(type, &state);
}
StackFrame* StackFrameIteratorBase::SingletonFor(StackFrame::Type type,
StackFrame::State* state) {
if (type == StackFrame::NONE) return NULL;
StackFrame* result = SingletonFor(type);
DCHECK(result != NULL);
result->state_ = *state;
DCHECK((!result) == (type == StackFrame::NONE));
if (result) result->state_ = *state;
return result;
}
......@@ -230,10 +228,8 @@ SafeStackFrameIterator::SafeStackFrameIterator(
} else {
return;
}
if (SingletonFor(type) == NULL) return;
frame_ = SingletonFor(type, &state);
DCHECK(frame_);
Advance();
if (frame_) Advance();
}
......@@ -261,12 +257,8 @@ void SafeStackFrameIterator::AdvanceOneFrame() {
// Advance to the previous frame.
StackFrame::State state;
StackFrame::Type type = frame_->GetCallerState(&state);
if (SingletonFor(type) == NULL) {
frame_ = NULL;
return;
}
frame_ = SingletonFor(type, &state);
DCHECK(frame_);
if (!frame_) return;
// Check that we have actually moved to the previous frame in the stack.
if (frame_->sp() < last_sp || frame_->fp() < last_fp) {
......
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