From 149a3d1345534b52b76cc5515de3af52b8c98707 Mon Sep 17 00:00:00 2001 From: Yagiz Nizipli Date: Thu, 2 Feb 2023 12:51:01 -0500 Subject: [PATCH 1/3] src: use simdutf utf8 to utf16 instead of icu --- src/inspector/main_thread_interface.cc | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/inspector/main_thread_interface.cc b/src/inspector/main_thread_interface.cc index 0cf75a37146729..23c34da7f58573 100644 --- a/src/inspector/main_thread_interface.cc +++ b/src/inspector/main_thread_interface.cc @@ -2,8 +2,9 @@ #include "env-inl.h" #include "node_mutex.h" -#include "v8-inspector.h" +#include "simdutf.h" #include "util-inl.h" +#include "v8-inspector.h" #include @@ -289,10 +290,12 @@ Deletable* MainThreadInterface::GetObjectIfExists(int id) { } 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()); + 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); } From 56e4773966e3b9ae5ca9d13bf6ddab3c1e62bf26 Mon Sep 17 00:00:00 2001 From: Yagiz Nizipli Date: Thu, 2 Feb 2023 12:53:20 -0500 Subject: [PATCH 2/3] src: use string_view instead of std::string& --- src/inspector/main_thread_interface.cc | 2 +- src/inspector/main_thread_interface.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/inspector/main_thread_interface.cc b/src/inspector/main_thread_interface.cc index 23c34da7f58573..3a673e021126aa 100644 --- a/src/inspector/main_thread_interface.cc +++ b/src/inspector/main_thread_interface.cc @@ -289,7 +289,7 @@ Deletable* MainThreadInterface::GetObjectIfExists(int id) { return iterator->second.get(); } -std::unique_ptr Utf8ToStringView(const std::string& message) { +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); 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>; From 313219abb5f334f8a8549d8e608083eab9f07aa8 Mon Sep 17 00:00:00 2001 From: Yagiz Nizipli Date: Fri, 3 Feb 2023 11:27:22 -0500 Subject: [PATCH 3/3] src: remove unused includes from main thread --- src/inspector/main_thread_interface.cc | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/inspector/main_thread_interface.cc b/src/inspector/main_thread_interface.cc index 3a673e021126aa..0a0afe8aeda0a9 100644 --- a/src/inspector/main_thread_interface.cc +++ b/src/inspector/main_thread_interface.cc @@ -1,13 +1,9 @@ #include "main_thread_interface.h" #include "env-inl.h" -#include "node_mutex.h" #include "simdutf.h" -#include "util-inl.h" #include "v8-inspector.h" -#include - #include #include