1
1
mirror of https://github.com/mawww/kakoune.git synced 2024-12-18 17:02:06 +03:00

Regex: small refactor of ThreadedRegexVM::clone_saves

This commit is contained in:
Maxime Coste 2017-10-03 18:23:31 +08:00
parent 9fbafba4cb
commit 119bc38254

View File

@ -76,21 +76,17 @@ struct ThreadedRegexVM
Saves* clone_saves(Saves* saves) Saves* clone_saves(Saves* saves)
{ {
Saves* res = nullptr;
if (not m_free_saves.empty()) if (not m_free_saves.empty())
{ {
res = m_free_saves.back(); Saves* res = m_free_saves.back();
m_free_saves.pop_back(); m_free_saves.pop_back();
} res->refcount = 1;
else res->pos = saves->pos;
{ return res;
m_saves.push_back(std::make_unique<Saves>());
res = m_saves.back().get();
} }
res->refcount = 1; m_saves.push_back(std::make_unique<Saves>(Saves{1, saves->pos}));
res->pos = saves->pos; return m_saves.back().get();
return res;
} }
struct Thread struct Thread