Skip to content

Commit

Permalink
src: provide faster string character counts
Browse files Browse the repository at this point in the history
  • Loading branch information
anonrig committed Feb 2, 2023
1 parent f84de0a commit 1a90cbb
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 1a90cbb

Please sign in to comment.