From 119bc38254cbae9a75591d95b80cabc8f343c7ea Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Tue, 3 Oct 2017 18:23:31 +0800 Subject: [PATCH] Regex: small refactor of ThreadedRegexVM::clone_saves --- src/regex_impl.hh | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/regex_impl.hh b/src/regex_impl.hh index b30b9735..0e992aed 100644 --- a/src/regex_impl.hh +++ b/src/regex_impl.hh @@ -76,21 +76,17 @@ struct ThreadedRegexVM Saves* clone_saves(Saves* saves) { - Saves* res = nullptr; if (not m_free_saves.empty()) { - res = m_free_saves.back(); + Saves* res = m_free_saves.back(); m_free_saves.pop_back(); - } - else - { - m_saves.push_back(std::make_unique()); - res = m_saves.back().get(); + res->refcount = 1; + res->pos = saves->pos; + return res; } - res->refcount = 1; - res->pos = saves->pos; - return res; + m_saves.push_back(std::make_unique(Saves{1, saves->pos})); + return m_saves.back().get(); } struct Thread