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

Function has_hex_prefix_unsafe

test-app/runtime/src/main/cpp/ada/ada.h:1013–1026  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1011namespace ada::checkers {
1012
1013constexpr bool has_hex_prefix_unsafe(std::string_view input) {
1014 // This is actually efficient code, see has_hex_prefix for the assembly.
1015 constexpr bool is_little_endian = std::endian::native == std::endian::little;
1016 constexpr uint16_t word0x = 0x7830;
1017 uint16_t two_first_bytes =
1018 static_cast<uint16_t>(input[0]) |
1019 static_cast<uint16_t>((static_cast<uint16_t>(input[1]) << 8));
1020 if constexpr (is_little_endian) {
1021 two_first_bytes |= 0x2000;
1022 } else {
1023 two_first_bytes |= 0x020;
1024 }
1025 return two_first_bytes == word0x;
1026}
1027
1028constexpr bool has_hex_prefix(std::string_view input) {
1029 return input.size() >= 2 && has_hex_prefix_unsafe(input);

Callers 1

has_hex_prefixFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected