From 1a90cbbd30536dbfd16df02a06dc5e0460bb01d7 Mon Sep 17 00:00:00 2001 From: Yagiz Nizipli Date: Thu, 2 Feb 2023 13:04:53 -0500 Subject: [PATCH] src: provide faster string character counts --- src/inspector/node_string.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/inspector/node_string.cc b/src/inspector/node_string.cc index 4cb8b573cc1312..c020130ae65c52 100644 --- a/src/inspector/node_string.cc +++ b/src/inspector/node_string.cc @@ -1,5 +1,6 @@ #include "node_string.h" #include "node/inspector/protocol/Protocol.h" +#include "simdutf.h" #include @@ -118,9 +119,8 @@ const uint8_t* CharactersUTF8(const String& s) { } size_t CharacterCount(const String& s) { - icu::UnicodeString utf16 = - icu::UnicodeString::fromUTF8(icu::StringPiece(s.data(), s.length())); - return utf16.countChar32(); + // TODO(@anonrig): Test to make sure CharacterCount returns correctly. + return simdutf::utf32_length_from_utf8(s.data(), s.length()); } } // namespace StringUtil