Coverage Report

Created: 2025-12-14 06:29

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/simdutf/src/scalar/swap_bytes.h
Line
Count
Source
1
#ifndef SIMDUTF_SWAP_BYTES_H
2
#define SIMDUTF_SWAP_BYTES_H
3
4
namespace simdutf {
5
namespace scalar {
6
7
constexpr inline simdutf_warn_unused uint16_t
8
166M
u16_swap_bytes(const uint16_t word) {
9
166M
  return uint16_t((word >> 8) | (word << 8));
10
166M
}
11
12
constexpr inline simdutf_warn_unused uint32_t
13
98.3k
u32_swap_bytes(const uint32_t word) {
14
98.3k
  return ((word >> 24) & 0xff) |      // move byte 3 to byte 0
15
98.3k
         ((word << 8) & 0xff0000) |   // move byte 1 to byte 2
16
98.3k
         ((word >> 8) & 0xff00) |     // move byte 2 to byte 1
17
98.3k
         ((word << 24) & 0xff000000); // byte 0 to byte 3
18
98.3k
}
19
20
namespace utf32 {
21
template <endianness big_endian> constexpr uint32_t swap_if_needed(uint32_t c) {
22
  return !match_system(big_endian) ? scalar::u32_swap_bytes(c) : c;
23
}
24
} // namespace utf32
25
26
namespace utf16 {
27
158M
template <endianness big_endian> constexpr uint16_t swap_if_needed(uint16_t c) {
28
158M
  return !match_system(big_endian) ? scalar::u16_swap_bytes(c) : c;
29
158M
}
unsigned short simdutf::scalar::utf16::swap_if_needed<(simdutf::endianness)1>(unsigned short)
Line
Count
Source
27
79.2M
template <endianness big_endian> constexpr uint16_t swap_if_needed(uint16_t c) {
28
79.2M
  return !match_system(big_endian) ? scalar::u16_swap_bytes(c) : c;
29
79.2M
}
unsigned short simdutf::scalar::utf16::swap_if_needed<(simdutf::endianness)0>(unsigned short)
Line
Count
Source
27
78.8M
template <endianness big_endian> constexpr uint16_t swap_if_needed(uint16_t c) {
28
78.8M
  return !match_system(big_endian) ? scalar::u16_swap_bytes(c) : c;
29
78.8M
}
30
} // namespace utf16
31
32
} // namespace scalar
33
} // namespace simdutf
34
35
#endif