MCPcopy Create free account
hub / github.com/NativeScript/android / ascii_map

Function ascii_map

test-app/runtime/src/main/cpp/ada/ada.cpp:2800–2823  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2798}
2799
2800void ascii_map(char* input, size_t length) {
2801 auto broadcast = [](uint8_t v) -> uint64_t {
2802 return 0x101010101010101ull * v;
2803 };
2804 uint64_t broadcast_80 = broadcast(0x80);
2805 uint64_t broadcast_Ap = broadcast(128 - 'A');
2806 uint64_t broadcast_Zp = broadcast(128 - 'Z' - 1);
2807 size_t i = 0;
2808
2809 for (; i + 7 < length; i += 8) {
2810 uint64_t word{};
2811 memcpy(&word, input + i, sizeof(word));
2812 word ^=
2813 (((word + broadcast_Ap) ^ (word + broadcast_Zp)) & broadcast_80) >> 2;
2814 memcpy(input + i, &word, sizeof(word));
2815 }
2816 if (i < length) {
2817 uint64_t word{};
2818 memcpy(&word, input + i, length - i);
2819 word ^=
2820 (((word + broadcast_Ap) ^ (word + broadcast_Zp)) & broadcast_80) >> 2;
2821 memcpy(input + i, &word, length - i);
2822 }
2823}
2824
2825// Map the characters according to IDNA, returning the empty string on error.
2826std::u32string map(std::u32string_view input) {

Callers 1

from_ascii_to_asciiFunction · 0.85

Calls 1

broadcastFunction · 0.85

Tested by

no test coverage detected