diff --git a/src/inspector/main_thread_interface.cc b/src/inspector/main_thread_interface.cc index 0cf75a37146729..0a0afe8aeda0a9 100644 --- a/src/inspector/main_thread_interface.cc +++ b/src/inspector/main_thread_interface.cc @@ -1,11 +1,8 @@ #include "main_thread_interface.h" #include "env-inl.h" -#include "node_mutex.h" +#include "simdutf.h" #include "v8-inspector.h" -#include "util-inl.h" - -#include #include #include @@ -288,11 +285,13 @@ Deletable* MainThreadInterface::GetObjectIfExists(int id) { return iterator->second.get(); } -std::unique_ptr Utf8ToStringView(const std::string& message) { - icu::UnicodeString utf16 = icu::UnicodeString::fromUTF8( - icu::StringPiece(message.data(), message.length())); - StringView view(reinterpret_cast(utf16.getBuffer()), - utf16.length()); +std::unique_ptr Utf8ToStringView(const std::string_view message) { + size_t expected_u16_length = + simdutf::utf16_length_from_utf8(message.data(), message.length()); + MaybeStackBuffer buffer(expected_u16_length); + size_t utf16_length = simdutf::convert_utf8_to_utf16( + message.data(), message.length(), buffer.out()); + StringView view(reinterpret_cast(buffer.out()), utf16_length); return StringBuffer::create(view); } diff --git a/src/inspector/main_thread_interface.h b/src/inspector/main_thread_interface.h index 3ec5b3db3e1600..71989db3bcacb9 100644 --- a/src/inspector/main_thread_interface.h +++ b/src/inspector/main_thread_interface.h @@ -34,7 +34,7 @@ class Deletable { }; std::unique_ptr Utf8ToStringView( - const std::string& message); + const std::string_view message); using MessageQueue = std::deque>;