mirror of
https://github.com/mawww/kakoune.git
synced 2024-08-16 16:20:38 +03:00
Revert "Always allocate saves"
This crashes in unit tests
This reverts commit cde5f5a258
.
This commit is contained in:
parent
24d719bf13
commit
f6762724ea
@ -313,10 +313,8 @@ private:
|
||||
template<bool copy>
|
||||
int16_t new_saves(Iterator* pos, uint32_t valid_mask)
|
||||
{
|
||||
if constexpr (mode & RegexMode::NoSaves)
|
||||
return -1;
|
||||
|
||||
kak_assert(not copy or pos != nullptr);
|
||||
const auto count = m_program.save_count;
|
||||
if (m_first_free >= 0)
|
||||
{
|
||||
const int16_t res = m_first_free;
|
||||
@ -329,7 +327,6 @@ private:
|
||||
return res;
|
||||
}
|
||||
|
||||
const auto count = m_program.save_count;
|
||||
auto* new_pos = reinterpret_cast<Iterator*>(operator new (count * sizeof(Iterator)));
|
||||
for (size_t i = 0; i < count; ++i)
|
||||
new (new_pos+i) Iterator{copy ? pos[i] : Iterator{}};
|
||||
@ -339,9 +336,8 @@ private:
|
||||
|
||||
void release_saves(int16_t index)
|
||||
{
|
||||
if constexpr (mode & RegexMode::NoSaves)
|
||||
if (index < 0)
|
||||
return;
|
||||
|
||||
auto& saves = m_saves[index];
|
||||
if (saves.refcount == 1)
|
||||
{
|
||||
@ -397,8 +393,7 @@ private:
|
||||
(config.flags & RegexExecFlags::NotInitialNull and pos == config.begin))
|
||||
return failed();
|
||||
|
||||
if (m_captures >= 0)
|
||||
release_saves(m_captures);
|
||||
release_saves(m_captures);
|
||||
m_captures = thread.saves;
|
||||
m_found_match = true;
|
||||
|
||||
@ -424,7 +419,8 @@ private:
|
||||
if (auto target = inst.param.split.target;
|
||||
instructions[target].last_step != current_step)
|
||||
{
|
||||
++m_saves[thread.saves].refcount;
|
||||
if (thread.saves >= 0)
|
||||
++m_saves[thread.saves].refcount;
|
||||
if (not inst.param.split.prioritize_parent)
|
||||
std::swap(thread.inst, target);
|
||||
m_threads.push_current({target, thread.saves});
|
||||
@ -433,7 +429,9 @@ private:
|
||||
case CompiledRegex::Save:
|
||||
if constexpr (mode & RegexMode::NoSaves)
|
||||
break;
|
||||
if (auto& saves = m_saves[thread.saves]; saves.refcount > 1)
|
||||
if (thread.saves < 0)
|
||||
thread.saves = new_saves<false>(nullptr, 0);
|
||||
else if (auto& saves = m_saves[thread.saves]; saves.refcount > 1)
|
||||
{
|
||||
--saves.refcount;
|
||||
thread.saves = new_saves<true>(saves.pos, saves.valid_mask);
|
||||
@ -473,13 +471,12 @@ private:
|
||||
bool exec_program(Iterator pos, const ExecConfig& config, auto&& idle_func)
|
||||
{
|
||||
kak_assert(m_threads.current_is_empty() and m_threads.next_is_empty());
|
||||
if (m_captures >= 0)
|
||||
release_saves(m_captures);
|
||||
release_saves(m_captures);
|
||||
m_captures = -1;
|
||||
m_threads.ensure_initial_capacity();
|
||||
|
||||
const int16_t first_inst = forward ? 0 : m_program.first_backward_inst;
|
||||
m_threads.push_current({first_inst, new_saves<false>(nullptr, 0)});
|
||||
m_threads.push_current({first_inst, -1});
|
||||
|
||||
const auto& start_desc = forward ? m_program.forward_start_desc : m_program.backward_start_desc;
|
||||
|
||||
@ -521,7 +518,7 @@ private:
|
||||
{
|
||||
if (start_desc and m_threads.next_is_empty())
|
||||
to_next_start(pos, config, *start_desc);
|
||||
m_threads.push_next({first_inst, new_saves<false>(nullptr, 0)});
|
||||
m_threads.push_next({first_inst, -1});
|
||||
}
|
||||
m_threads.swap_next();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user