Skip to content
This repository has been archived by the owner on May 3, 2024. It is now read-only.

Commit

Permalink
Remove next_next
Browse files Browse the repository at this point in the history
  • Loading branch information
MBkkt committed Sep 16, 2023
1 parent dcd2398 commit d6ef477
Showing 1 changed file with 9 additions and 29 deletions.
38 changes: 9 additions & 29 deletions external/text/include/boost/text/word_break.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,6 @@ namespace boost { namespace text {
word_break_state() {}
CPIter it;
CPIter it_next;
CPIter it_next_next;

bool it_points_to_prev = false;

Expand All @@ -221,13 +220,11 @@ namespace boost { namespace text {
state.caps[0] = state.caps[1];
state.caps[1] = state.caps[2];
state.caps[2] = state.caps[3];
state.caps[3] = state.caps[4];
state.caps[4] = cp_and_word_prop{};
state.caps[3] = cp_and_word_prop{};

state.it = state.it_next;
state.it_next = state.it_next_next;
if (state.it_next_next != last) {
++state.it_next_next;
if (state.it_next != last) {
++state.it_next;
}

return state;
Expand Down Expand Up @@ -308,14 +305,9 @@ constexpr std::array<std::array<bool, 20>, 20> word_breaks = {{
}
state.caps[ph::curr] = cp_and_word_prop(*state.it, word_prop);
state.caps[ph::next] = cp_and_word_prop();
state.caps[ph::next_next] = cp_and_word_prop();
state.it_next_next = state.it_next = std::next(state.it);
state.it_next = std::next(state.it);
if (state.it_next != last) {
state.caps[ph::next] = cp_and_word_prop(*state.it_next, word_prop);
++state.it_next_next;
if (state.it_next_next != last) {
state.caps[ph::next_next] = cp_and_word_prop(*state.it_next_next, word_prop);
}
}
}
}
Expand Down Expand Up @@ -712,6 +704,8 @@ constexpr std::array<std::array<bool, 20>, 20> word_breaks = {{
WordPropFunc const & word_prop = WordPropFunc{},
WordBreakFunc const & word_break = WordBreakFunc{}) noexcept
{
static_assert(std::is_same_v<WordBreakFunc, untailored_word_break>,
"Otherwise you need to revert changes for this function about next_next");
using detail::ph;
using detail::cp_and_word_prop;

Expand All @@ -726,30 +720,16 @@ constexpr std::array<std::array<bool, 20>, 20> word_breaks = {{

state.caps[ph::prev] = cp_and_word_prop(*first, word_prop);
state.caps[ph::curr] = cp_and_word_prop(*state.it, word_prop);
state.it_next_next = state.it_next = std::next(state.it);
if (state.it_next != last) {
state.caps[ph::next] = cp_and_word_prop(*state.it_next, word_prop);
++state.it_next_next;
}
state.it_next = std::next(state.it);

state.emoji_state =
state.caps[ph::prev].prop == word_property::Regional_Indicator
? detail::word_break_emoji_state_t::first_emoji
: detail::word_break_emoji_state_t::none;

for (; state.it != last; state = detail::next(state, last)) {
if (state.it_next_next != last) {
state.caps[ph::next_next] = cp_and_word_prop(*state.it_next_next, word_prop);
}

// Check word_break before anything else.
if (word_break(
state.caps[ph::prev_prev].cp,
state.caps[ph::prev].cp,
state.caps[ph::curr].cp,
state.caps[ph::next].cp,
state.caps[ph::next_next].cp)) {
return state.it;
if (state.it_next != last) {
state.caps[ph::next] = cp_and_word_prop(*state.it_next, word_prop);
}

// WB3
Expand Down

0 comments on commit d6ef477

Please sign in to comment.