Commit b51ee85c authored by Leszek Swirski's avatar Leszek Swirski Committed by Commit Bot

Revert "[scanner] Micro-optimize AdvanceUntil"

This reverts commit bfc9eb2e.

Reason for revert: Micro-benchmark regressions (crbug.com/923823)

Original change's description:
> [scanner] Micro-optimize AdvanceUntil
> 
> Replace std::find_if in AdvanceUntil with a manual loop, which can
> then return early, skipping the branch comparing to buffer_end_.
> 
> Change-Id: If49ed3667877751fcb0103a742750f03e5bd50db
> Reviewed-on: https://chromium-review.googlesource.com/c/1411351
> Reviewed-by: Toon Verwaest <verwaest@chromium.org>
> Commit-Queue: Leszek Swirski <leszeks@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#58846}

TBR=leszeks@chromium.org,verwaest@chromium.org

# Not skipping CQ checks because original CL landed > 1 day ago.
Bug: 923823

Change-Id: I2475e18fb1d52d47b32b34e261c6f1aa46b3c1ce
Reviewed-on: https://chromium-review.googlesource.com/c/1425200Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/master@{#58962}
parent ce2bfb8e
......@@ -71,18 +71,21 @@ class Utf16CharacterStream {
template <typename FunctionType>
V8_INLINE uc32 AdvanceUntil(FunctionType check) {
while (true) {
for (; buffer_cursor_ < buffer_end_; ++buffer_cursor_) {
uc32 c0_ = static_cast<uc32>(*buffer_cursor_);
if (check(c0_)) {
auto next_cursor_pos =
std::find_if(buffer_cursor_, buffer_end_, [&check](uint16_t raw_c0_) {
uc32 c0_ = static_cast<uc32>(raw_c0_);
return check(c0_);
});
if (next_cursor_pos == buffer_end_) {
buffer_cursor_ = buffer_end_;
if (!ReadBlockChecked()) {
buffer_cursor_++;
return c0_;
return kEndOfInput;
}
}
DCHECK_EQ(buffer_cursor_, buffer_end_);
if (!ReadBlockChecked()) {
buffer_cursor_++;
return kEndOfInput;
} else {
buffer_cursor_ = next_cursor_pos + 1;
return static_cast<uc32>(*next_cursor_pos);
}
}
}
......
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