diff --git a/include/fast_io_core_impl/integers/sto/sto_contiguous.h b/include/fast_io_core_impl/integers/sto/sto_contiguous.h index 51653854..c88fd871 100644 --- a/include/fast_io_core_impl/integers/sto/sto_contiguous.h +++ b/include/fast_io_core_impl/integers/sto/sto_contiguous.h @@ -949,11 +949,11 @@ template inline constexpr parse_result scan_shbase_impl(char_type const *first, char_type const *last) noexcept { - if (first == last || *first != char_literal_v) + if (first == last || *first != char_literal_v) [[unlikely]] { return {first, parse_code::invalid}; } - if ((++first) == last) + if ((++first) == last) [[unlikely]] { return {first, parse_code::invalid}; } @@ -961,7 +961,7 @@ inline constexpr parse_result scan_shbase_impl(char_type cons { auto ch{*first}; if ((ch != char_literal_v<(base == 2 ? u8'B' : (base == 3 ? u8't' : u8'X')), char_type>)&( - ch != char_literal_v<(base == 2 ? u8'b' : (base == 3 ? u8't' : u8'x')), char_type>)) + ch != char_literal_v<(base == 2 ? u8'b' : (base == 3 ? u8't' : u8'x')), char_type>)) [[unlikely]] { return {first, parse_code::invalid}; } @@ -969,37 +969,37 @@ inline constexpr parse_result scan_shbase_impl(char_type cons } else { - if (*first != char_literal_v) + if (*first != char_literal_v) [[unlikely]] { return {first, parse_code::invalid}; } ++first; - if ((++first) == last) + if ((++first) == last) [[unlikely]] { return {first, parse_code::invalid}; } constexpr auto digit0{char_literal_v}; - if (*first != digit0) + if (*first != digit0) [[unlikely]] { return {first, parse_code::invalid}; } - if ((++first) == last) + if ((++first) == last) [[unlikely]] { return {first, parse_code::invalid}; } if constexpr (10 < base) { constexpr auto digit1{char_literal_v}; - if (*first != digit1) + if (*first != digit1) [[unlikely]] { return {first, parse_code::invalid}; } - if ((++first) == last) + if ((++first) == last) [[unlikely]] { return {first, parse_code::invalid}; } } - if (*first != char_literal_v) + if (*first != char_literal_v) [[unlikely]] { return {first, parse_code::invalid}; } @@ -1018,7 +1018,7 @@ scan_int_contiguous_none_space_part_define_impl(char_type const *first, char_typ [[maybe_unused]] bool sign{}; if constexpr (my_signed_integral) { - if (first == last) + if (first == last) [[unlikely]] { return {first, parse_code::invalid}; } @@ -1031,7 +1031,7 @@ scan_int_contiguous_none_space_part_define_impl(char_type const *first, char_typ { if constexpr (base == 8) { - if (first == last || *first != char_literal_v) + if (first == last || *first != char_literal_v) [[unlikely]] { return {first, parse_code::invalid}; } @@ -1040,7 +1040,7 @@ scan_int_contiguous_none_space_part_define_impl(char_type const *first, char_typ else { auto phase_ret = scan_shbase_impl(first, last); - if (phase_ret.code != ongoing_parse_code) + if (phase_ret.code != ongoing_parse_code) [[unlikely]] { return phase_ret; } @@ -1062,7 +1062,7 @@ scan_int_contiguous_none_space_part_define_impl(char_type const *first, char_typ { ++first; first = ::fast_io::details::find_none_zero_simd_impl(first, last); - if (first == last) + if (first == last) [[likely]] { t = 0; return {first, parse_code::ok}; @@ -1071,7 +1071,7 @@ scan_int_contiguous_none_space_part_define_impl(char_type const *first, char_typ else { ++first; - if ((first == last) || (!char_is_digit(static_cast(*first)))) + if ((first == last) || (!char_is_digit(static_cast(*first)))) [[likely]] { t = {}; return {first, parse_code::ok}; @@ -1104,7 +1104,7 @@ scan_int_contiguous_none_space_part_define_impl(char_type const *first, char_typ if constexpr (smaller_than_uint64) { constexpr unsigned_type umax{static_cast(-1)}; - if (temp > umax) + if (temp > umax) [[unlikely]] { return {it, parse_code::overflow}; } @@ -1118,7 +1118,7 @@ scan_int_contiguous_none_space_part_define_impl(char_type const *first, char_typ else [[unlikely]] { auto [it2, ec] = scan_int_contiguous_none_simd_space_part_define_impl(first, last, res); - if (ec != parse_code::ok) + if (ec != parse_code::ok) [[unlikely]] { return {it2, ec}; } @@ -1129,7 +1129,7 @@ scan_int_contiguous_none_space_part_define_impl(char_type const *first, char_typ #endif { auto [it2, ec] = scan_int_contiguous_none_simd_space_part_define_impl(first, last, res); - if (ec != parse_code::ok) + if (ec != parse_code::ok) [[unlikely]] { return {it2, ec}; } @@ -1139,7 +1139,7 @@ scan_int_contiguous_none_space_part_define_impl(char_type const *first, char_typ { constexpr unsigned_type umax{static_cast(-1)}; constexpr unsigned_type imax{umax >> 1}; - if (res > (static_cast>(imax) + sign)) + if (res > (static_cast>(imax) + sign)) [[unlikely]] { return {it, parse_code::overflow}; } @@ -1177,7 +1177,7 @@ inline constexpr parse_result scan_int_contiguous_define_impl { if constexpr (base == 8) { - if (first == last || *first != char_literal_v) + if (first == last || *first != char_literal_v) [[unlikely]] { return {first, parse_code::invalid}; } @@ -1186,7 +1186,7 @@ inline constexpr parse_result scan_int_contiguous_define_impl else { auto phase_ret = scan_shbase_impl(first, last); - if (phase_ret.code != ongoing_parse_code) + if (phase_ret.code != ongoing_parse_code) [[unlikely]] { return phase_ret; } @@ -1310,7 +1310,7 @@ sc_int_ctx_prefix_phase(::std::uint_least8_t &sz, char_type const *first, char_t } if constexpr (base == 8) { - if (*first != char_literal_v) + if (*first != char_literal_v) [[unlikely]] { return {first, parse_code::invalid}; } @@ -1320,7 +1320,7 @@ sc_int_ctx_prefix_phase(::std::uint_least8_t &sz, char_type const *first, char_t ::std::uint_least8_t size_cache{sz}; if (size_cache == 0) { - if (*first != char_literal_v) + if (*first != char_literal_v) [[unlikely]] { return {first, parse_code::invalid}; } @@ -1338,13 +1338,13 @@ sc_int_ctx_prefix_phase(::std::uint_least8_t &sz, char_type const *first, char_t { auto ch{*first}; if ((ch == char_literal_v<(base == 2 ? u8'B' : (base == 3 ? u8't' : u8'X')), char_type>) | - (ch == char_literal_v<(base == 2 ? u8'b' : (base == 3 ? u8't' : u8'x')), char_type>)) + (ch == char_literal_v<(base == 2 ? u8'b' : (base == 3 ? u8't' : u8'x')), char_type>)) [[likely]] { sz = 0; ++first; return {first, ongoing_parse_code}; } - else + else [[unlikely]] { return {first, parse_code::invalid}; } @@ -1353,7 +1353,7 @@ sc_int_ctx_prefix_phase(::std::uint_least8_t &sz, char_type const *first, char_t { if (size_cache == 1) { - if (*first != char_literal_v) + if (*first != char_literal_v) [[unlikely]] { return {first, parse_code::invalid}; } @@ -1366,7 +1366,7 @@ sc_int_ctx_prefix_phase(::std::uint_least8_t &sz, char_type const *first, char_t constexpr auto digit0{char_literal_v}; if (size_cache == 2) { - if (*first != digit0) + if (*first != digit0) [[unlikely]] { return {first, parse_code::invalid}; } @@ -1381,7 +1381,7 @@ sc_int_ctx_prefix_phase(::std::uint_least8_t &sz, char_type const *first, char_t constexpr auto digit1{char_literal_v}; if (size_cache == 3) { - if (*first != digit1) + if (*first != digit1) [[unlikely]] { return {first, parse_code::invalid}; } @@ -1395,7 +1395,7 @@ sc_int_ctx_prefix_phase(::std::uint_least8_t &sz, char_type const *first, char_t constexpr ::std::uint_least8_t last_index{base < 10 ? 3 : 4}; if (size_cache == last_index) { - if (*first != char_literal_v) + if (*first != char_literal_v) [[unlikely]] { return {first, parse_code::invalid}; } @@ -1443,7 +1443,7 @@ inline constexpr parse_result sc_int_ctx_zero_phase(scan_inte } return {first, parse_code::partial}; } - if (!char_is_digit(static_cast(*first))) + if (!char_is_digit(static_cast(*first))) [[likely]] { return {first, parse_code::ok}; } @@ -1472,7 +1472,7 @@ inline constexpr parse_result sc_int_ctx_digit_phase(State &s st.integer_phase = scan_integral_context_phase::digit; return {it, parse_code::partial}; } - if (st.size == 0) + if (st.size == 0) [[likely]] { t = {}; return {it, parse_code::ok}; @@ -1487,7 +1487,7 @@ inline constexpr parse_result sc_int_ctx_digit_phase(State &s st.integer_phase = scan_integral_context_phase::overflow; return {it, parse_code::partial}; } - else + else [[unlikely]] { return {it, parse_code::overflow}; } @@ -1504,7 +1504,7 @@ inline constexpr parse_result sc_int_ctx_zero_invalid_phase(c return {first, parse_code::partial}; } ++first; - if (!char_is_digit(static_cast(*first))) + if (!char_is_digit(static_cast(*first))) [[likely]] { return {first, parse_code::ok}; } @@ -1554,7 +1554,7 @@ inline constexpr parse_result scan_context_define_parse_impl( if constexpr (!noskipws) { auto phase_ret = sc_int_ctx_space_phase(first, last); - if (phase_ret.code != ongoing_parse_code) + if (phase_ret.code != ongoing_parse_code) [[unlikely]] { return phase_ret; } @@ -1673,9 +1673,7 @@ inline constexpr parse_code scan_context_eof_define_parse_impl(State &st, T &t) } } case scan_integral_context_phase::digit: - return scan_int_contiguous_none_space_part_define_impl(st.buffer.data(), st.buffer.data() + st.size, - t) - .code; + return scan_int_contiguous_none_space_part_define_impl(st.buffer.data(), st.buffer.data() + st.size, t).code; case scan_integral_context_phase::overflow: return parse_code::overflow; case scan_integral_context_phase::zero_skip: