utils/utf8.c: move includes outside of namespaces

Including in the middle of a namespace is not a good practice.

Signed-off-by: Botond Dénes <bdenes@scylladb.com>
Message-Id: <20210528142502.962947-1-bdenes@scylladb.com>
This commit is contained in:
Botond Dénes
2021-05-28 17:25:02 +03:00
committed by Avi Kivity
parent a7cdd846da
commit cd6bbd37a4

View File

@@ -156,9 +156,17 @@ validate_partial_naive(const uint8_t *data, size_t len) {
return partial_validation_results{};
}
} // namespace utf8
} // namespace utils
#if defined(__aarch64__)
#include <arm_neon.h>
namespace utils {
namespace utf8 {
// Map high nibble of "First Byte" to legal character length minus 1
// 0x00 ~ 0xBF --> 0
// 0xC0 ~ 0xDF --> 1
@@ -352,9 +360,17 @@ internal::validate_partial(const uint8_t *data, size_t len) {
return validate_partial_naive(data, len);
}
} // namespace utf8
} // namespace utils
#elif defined(__x86_64__)
#include <smmintrin.h>
namespace utils {
namespace utf8 {
// Map high nibble of "First Byte" to legal character length minus 1
// 0x00 ~ 0xBF --> 0
// 0xC0 ~ 0xDF --> 1
@@ -537,8 +553,16 @@ internal::validate_partial(const uint8_t *data, size_t len) {
return validate_partial_naive(data, len);
}
} // namespace utf8
} // namespace utils
#else
namespace utils {
namespace utf8 {
namespace internal {
// No SIMD implementation for this arch, fallback to naive method
@@ -549,8 +573,16 @@ validate_partial(const uint8_t *data, size_t len) {
}
} // namespace utf8
} // namespace utils
#endif
namespace utils {
namespace utf8 {
bool validate(const uint8_t* data, size_t len) {
auto pvr = validate_partial(data, len);
return !pvr.error && !pvr.unvalidated_tail;