We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d4f0460 commit 62af4d3Copy full SHA for 62af4d3
src/string_bytes.cc
@@ -539,9 +539,10 @@ MaybeLocal<Value> StringBytes::Encode(Isolate* isolate,
539
return ExternOneByteString::NewFromCopy(isolate, buf, buflen);
540
}
541
542
- if (simdutf::validate_utf8(buf, buflen)) {
+ if (buflen >= 32 && simdutf::validate_utf8(buf, buflen)) {
543
// We know that we are non-ASCII (and are unlikely Latin1), use 2-byte
544
// In the most likely case of valid UTF-8, we can use this fast impl
545
+ // For very short input, it is slower, so we limit min size
546
size_t u16size = simdutf::utf16_length_from_utf8(buf, buflen);
547
if (u16size > static_cast<size_t>(v8::String::kMaxLength)) {
548
isolate->ThrowException(ERR_STRING_TOO_LONG(isolate));
0 commit comments