aboutsummaryrefslogtreecommitdiff
path: root/deps/v8/src/parsing/scanner-character-streams.cc
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/src/parsing/scanner-character-streams.cc')
-rw-r--r--deps/v8/src/parsing/scanner-character-streams.cc12
1 files changed, 11 insertions, 1 deletions
diff --git a/deps/v8/src/parsing/scanner-character-streams.cc b/deps/v8/src/parsing/scanner-character-streams.cc
index 7758b2bb73..01ea0a0d02 100644
--- a/deps/v8/src/parsing/scanner-character-streams.cc
+++ b/deps/v8/src/parsing/scanner-character-streams.cc
@@ -590,7 +590,8 @@ void Utf8ExternalStreamingStream::FillBufferFromCurrentChunk() {
}
}
- while (cursor < end && output_cursor + 1 < buffer_start_ + kBufferSize) {
+ const uint16_t* max_buffer_end = buffer_start_ + kBufferSize;
+ while (cursor < end && output_cursor + 1 < max_buffer_end) {
unibrow::uchar t =
unibrow::Utf8::ValueOfIncremental(&cursor, &state, &incomplete_char);
if (V8_LIKELY(t <= unibrow::Utf16::kMaxNonSurrogateCharCode)) {
@@ -601,6 +602,15 @@ void Utf8ExternalStreamingStream::FillBufferFromCurrentChunk() {
*(output_cursor++) = unibrow::Utf16::LeadSurrogate(t);
*(output_cursor++) = unibrow::Utf16::TrailSurrogate(t);
}
+ // Fast path for ascii sequences.
+ size_t remaining = end - cursor;
+ size_t max_buffer = max_buffer_end - output_cursor;
+ int max_length = static_cast<int>(Min(remaining, max_buffer));
+ DCHECK_EQ(state, unibrow::Utf8::State::kAccept);
+ int ascii_length = NonAsciiStart(cursor, max_length);
+ CopyChars(output_cursor, cursor, ascii_length);
+ cursor += ascii_length;
+ output_cursor += ascii_length;
}
current_.pos.bytes = chunk.start.bytes + (cursor - chunk.data);