mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
src: replace icu with simdutf for char counts
PR-URL: https://github.com/nodejs/node/pull/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>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#include "node_string.h"
|
||||
#include "node/inspector/protocol/Protocol.h"
|
||||
#include "simdutf.h"
|
||||
|
||||
#include <unicode/unistr.h>
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user