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 58ce8e9
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/inspector/node_string.cc
Original file line number Diff line number Diff line change
@@ -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: Add a test to validate CharacterCount returns correct value.
return simdutf::utf32_length_from_utf8(s.data(), s.length());
}

} // namespace StringUtil
Expand Down

0 comments on commit 58ce8e9

Please sign in to comment.