diff options
| author | Maxime Coste <mawww@kakoune.org> | 2025-07-07 13:12:26 +1000 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2025-07-07 13:12:26 +1000 |
| commit | eba45e575f8ca624a9a3505d3c15059e14d0b642 (patch) | |
| tree | 2505d241d8e6c59c6696c1cae6bdaf1c78410d9b /src | |
| parent | 3c92a6650d721fdc8fb98e83b30795e6d2984f20 (diff) | |
Use uint32_t for DualThreadStack indices
Diffstat (limited to 'src')
| -rw-r--r-- | src/regex_impl.hh | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/regex_impl.hh b/src/regex_impl.hh index 2f5cbcfa..fa6c2603 100644 --- a/src/regex_impl.hh +++ b/src/regex_impl.hh @@ -725,9 +725,9 @@ private: Thread* new_data = new Thread[new_capacity]; Thread* old_data = m_data.get(); std::rotate_copy(old_data, old_data + m_current, old_data + capacity, new_data); - m_next_begin -= m_current; - if ((pushed_current and m_next_begin == 0) or m_next_begin < 0) - m_next_begin += capacity; + m_next_begin = (m_next_begin - m_current) & m_capacity_mask; + if (pushed_current and m_next_begin == 0) + m_next_begin = capacity; m_next_end = capacity; m_current = 0; @@ -737,13 +737,13 @@ private: } private: - int32_t decrement(int32_t& index) + uint32_t decrement(uint32_t& index) { index = (index - 1) & m_capacity_mask; return index; } - int32_t post_increment(int32_t& index) + uint32_t post_increment(uint32_t& index) { auto res = index; index = (index + 1) & m_capacity_mask; @@ -752,9 +752,9 @@ private: std::unique_ptr<Thread[]> m_data; uint32_t m_capacity_mask = 0; // Maximum capacity should be 2*instruction count, so 65536 - int32_t m_current = 0; - int32_t m_next_begin = 0; - int32_t m_next_end = 0; + uint32_t m_current = 0; + uint32_t m_next_begin = 0; + uint32_t m_next_end = 0; }; static constexpr bool forward = mode & RegexMode::Forward; |
