MCPcopy Create free account
hub / github.com/CodingGay/BlackDex / ComputeUtf16HashFromModifiedUtf8

Function ComputeUtf16HashFromModifiedUtf8

Bcore/src/main/cpp/dex/utf.cc:178–193  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

176}
177
178int32_t ComputeUtf16HashFromModifiedUtf8(const char* utf8, size_t utf16_length) {
179 uint32_t hash = 0;
180 while (utf16_length != 0u) {
181 const uint32_t pair = GetUtf16FromUtf8(&utf8);
182 const uint16_t first = GetLeadingUtf16Char(pair);
183 hash = hash * 31 + first;
184 --utf16_length;
185 const uint16_t second = GetTrailingUtf16Char(pair);
186 if (second != 0) {
187 hash = hash * 31 + second;
188 DCHECK_NE(utf16_length, 0u);
189 --utf16_length;
190 }
191 }
192 return static_cast<int32_t>(hash);
193}
194
195uint32_t ComputeModifiedUtf8Hash(const char* chars) {
196 uint32_t hash = 0;

Callers

nothing calls this directly

Calls 3

GetUtf16FromUtf8Function · 0.85
GetLeadingUtf16CharFunction · 0.85
GetTrailingUtf16CharFunction · 0.85

Tested by

no test coverage detected