Skip to content

Commit

Permalink
src: replace icu with simdutf for char counts
Browse files Browse the repository at this point in the history
PR-URL: #46472
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
  • Loading branch information
anonrig authored and MylesBorins committed Feb 18, 2023
1 parent 375bb22 commit 00b81c7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/inspector/node_string.cc
@@ -1,5 +1,6 @@
#include "node_string.h"
#include "node/inspector/protocol/Protocol.h"
#include "simdutf.h"

#include <unicode/unistr.h>

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 00b81c7

Please sign in to comment.