Skip to content

Commit aabbe55

Browse files
committed
src: restore ASCII fast path in EncodeValidUtf8
1 parent e41315d commit aabbe55

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

src/string_bytes.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,9 @@ MaybeLocal<Value> StringBytes::EncodeValidUtf8(Isolate* isolate,
559559
const char* buf,
560560
size_t buflen) {
561561
buflen = keep_buflen_in_range(buflen);
562+
if (!simdutf::validate_ascii_with_errors(buf, buflen).error) {
563+
return ExternOneByteString::NewFromCopy(isolate, buf, buflen);
564+
}
562565
if (buflen >= 32) return EncodeValidNonAsciiUtf8(isolate, buf, buflen);
563566
Local<String> str;
564567
if (!String::NewFromUtf8(isolate, buf, v8::NewStringType::kNormal, buflen)

0 commit comments

Comments
 (0)