diff options
| author | Amlal <amlal@nekernel.org> | 2025-08-11 23:31:39 +0200 |
|---|---|---|
| committer | Amlal <amlal@nekernel.org> | 2025-08-11 23:31:39 +0200 |
| commit | d987d62459d59a6d95ffb815d5e6eccd8dbde1dd (patch) | |
| tree | d91d1351193a9f758daa9dad964e40f5a84ece7f /vendor/toml++/impl/unicode.inl | |
| parent | 4c462511485168cfc831a1447267fd76145d5183 (diff) | |
meta: ran format command.v0.0.3-release
Signed-off-by: Amlal <amlal@nekernel.org>
Diffstat (limited to 'vendor/toml++/impl/unicode.inl')
| -rw-r--r-- | vendor/toml++/impl/unicode.inl | 70 |
1 files changed, 32 insertions, 38 deletions
diff --git a/vendor/toml++/impl/unicode.inl b/vendor/toml++/impl/unicode.inl index 4064c58..93a7d52 100644 --- a/vendor/toml++/impl/unicode.inl +++ b/vendor/toml++/impl/unicode.inl @@ -1,59 +1,53 @@ -//# This file is a part of toml++ and is subject to the the terms of the MIT license. -//# Copyright (c) Mark Gillard <mark.gillard@outlook.com.au> -//# See https://github.com/marzer/tomlplusplus/blob/master/LICENSE for the full license text. -// SPDX-License-Identifier: MIT +// # This file is a part of toml++ and is subject to the the terms of the MIT license. +// # Copyright (c) Mark Gillard <mark.gillard@outlook.com.au> +// # See https://github.com/marzer/tomlplusplus/blob/master/LICENSE for the full license text. +// SPDX-License-Identifier: MIT #pragma once -//# {{ +// # {{ #include "preprocessor.hpp" #if !TOML_IMPLEMENTATION #error This is an implementation-only header. #endif -//# }} +// # }} -#include "unicode.hpp" -#include "simd.hpp" #include "header_start.hpp" +#include "simd.hpp" +#include "unicode.hpp" -TOML_IMPL_NAMESPACE_START -{ - TOML_PURE_GETTER - TOML_EXTERNAL_LINKAGE - bool is_ascii(const char* str, size_t len) noexcept - { - const char* const end = str + len; +TOML_IMPL_NAMESPACE_START { + TOML_PURE_GETTER + TOML_EXTERNAL_LINKAGE + bool is_ascii(const char* str, size_t len) noexcept { + const char* const end = str + len; #if TOML_HAS_SSE2 && (128 % CHAR_BIT) == 0 - { - constexpr size_t chars_per_vector = 128u / CHAR_BIT; - - if (const size_t simdable = len - (len % chars_per_vector)) - { - __m128i mask = _mm_setzero_si128(); - for (const char* const e = str + simdable; str < e; str += chars_per_vector) - { - const __m128i current_bytes = _mm_loadu_si128(reinterpret_cast<const __m128i*>(str)); - mask = _mm_or_si128(mask, current_bytes); - } - const __m128i has_error = _mm_cmpgt_epi8(_mm_setzero_si128(), mask); + { + constexpr size_t chars_per_vector = 128u / CHAR_BIT; + + if (const size_t simdable = len - (len % chars_per_vector)) { + __m128i mask = _mm_setzero_si128(); + for (const char* const e = str + simdable; str < e; str += chars_per_vector) { + const __m128i current_bytes = _mm_loadu_si128(reinterpret_cast<const __m128i*>(str)); + mask = _mm_or_si128(mask, current_bytes); + } + const __m128i has_error = _mm_cmpgt_epi8(_mm_setzero_si128(), mask); #if TOML_HAS_SSE4_1 - if (!_mm_testz_si128(has_error, has_error)) - return false; + if (!_mm_testz_si128(has_error, has_error)) return false; #else - if (_mm_movemask_epi8(_mm_cmpeq_epi8(has_error, _mm_setzero_si128())) != 0xFFFF) - return false; + if (_mm_movemask_epi8(_mm_cmpeq_epi8(has_error, _mm_setzero_si128())) != 0xFFFF) + return false; #endif - } - } + } + } #endif - for (; str < end; str++) - if (static_cast<unsigned char>(*str) > 127u) - return false; + for (; str < end; str++) + if (static_cast<unsigned char>(*str) > 127u) return false; - return true; - } + return true; + } } TOML_IMPL_NAMESPACE_END; |
