Revert "[scanner] Micro-optimize AdvanceUntil"
This reverts commit bfc9eb2e8c
.
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/1425200
Reviewed-by: Leszek Swirski <leszeks@chromium.org>
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/master@{#58962}
This commit is contained in:
parent
ce2bfb8e2f
commit
b51ee85c0f
@ -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_)) {
|
||||
buffer_cursor_++;
|
||||
return 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_);
|
||||
});
|
||||
|
||||
DCHECK_EQ(buffer_cursor_, buffer_end_);
|
||||
if (!ReadBlockChecked()) {
|
||||
buffer_cursor_++;
|
||||
return kEndOfInput;
|
||||
if (next_cursor_pos == buffer_end_) {
|
||||
buffer_cursor_ = buffer_end_;
|
||||
if (!ReadBlockChecked()) {
|
||||
buffer_cursor_++;
|
||||
return kEndOfInput;
|
||||
}
|
||||
} else {
|
||||
buffer_cursor_ = next_cursor_pos + 1;
|
||||
return static_cast<uc32>(*next_cursor_pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user