From d9e44dfacf64b7a04aeccf110e2d54bd89f5ecaf Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Mon, 5 Mar 2018 03:10:47 +1100 Subject: [PATCH] Regex: Remove helper functions from regex_impl.hh They were close duplicates from the ones in regex.hh and not used anywhere else. --- src/regex.hh | 22 ++++++++++++++++++---- src/regex_impl.hh | 42 ------------------------------------------ 2 files changed, 18 insertions(+), 46 deletions(-) diff --git a/src/regex.hh b/src/regex.hh index cbd4a14a6..4d8fa95cb 100644 --- a/src/regex.hh +++ b/src/regex.hh @@ -113,21 +113,29 @@ inline RegexExecFlags match_flags(bool bol, bool eol, bool bow, bool eow, bool b template bool regex_match(It begin, It end, const Regex& re) { - return regex_match(begin, end, *re.impl()); + ThreadedRegexVM vm{*re.impl()}; + return vm.exec(begin, end, RegexExecFlags::AnyMatch | RegexExecFlags::NoSaves); } template bool regex_match(It begin, It end, MatchResults& res, const Regex& re) { res.values().clear(); - return regex_match(begin, end, res.values(), *re.impl()); + ThreadedRegexVM vm{*re.impl()}; + if (vm.exec(begin, end, RegexExecFlags::None)) + { + std::copy(vm.captures().begin(), vm.captures().end(), std::back_inserter(res.values())); + return true; + } + return false; } template bool regex_search(It begin, It end, const Regex& re, RegexExecFlags flags = RegexExecFlags::None) { - return regex_search(begin, end, *re.impl(), flags); + ThreadedRegexVM vm{*re.impl()}; + return vm.exec(begin, end, flags | RegexExecFlags::Search | RegexExecFlags::AnyMatch | RegexExecFlags::NoSaves); } template @@ -135,7 +143,13 @@ bool regex_search(It begin, It end, MatchResults& res, const Regex& re, RegexExecFlags flags = RegexExecFlags::None) { res.values().clear(); - return regex_search(begin, end, res.values(), *re.impl(), flags); + ThreadedRegexVM vm{*re.impl()}; + if (vm.exec(begin, end, flags | RegexExecFlags::Search)) + { + std::move(vm.captures().begin(), vm.captures().end(), std::back_inserter(res.values())); + return true; + } + return false; } template diff --git a/src/regex_impl.hh b/src/regex_impl.hh index 8fe40d169..ff9c8c0d9 100644 --- a/src/regex_impl.hh +++ b/src/regex_impl.hh @@ -573,48 +573,6 @@ private: Saves* m_captures = nullptr; }; -template -bool regex_match(It begin, It end, const CompiledRegex& re, RegexExecFlags flags = RegexExecFlags::None) -{ - ThreadedRegexVM vm{re}; - return vm.exec(begin, end, (RegexExecFlags)(flags & ~(RegexExecFlags::Search)) | - RegexExecFlags::AnyMatch | RegexExecFlags::NoSaves); -} - -template -bool regex_match(It begin, It end, Vector& captures, const CompiledRegex& re, - RegexExecFlags flags = RegexExecFlags::None) -{ - ThreadedRegexVM vm{re}; - if (vm.exec(begin, end, flags & ~(RegexExecFlags::Search))) - { - std::copy(vm.captures().begin(), vm.captures().end(), std::back_inserter(captures)); - return true; - } - return false; -} - -template -bool regex_search(It begin, It end, const CompiledRegex& re, - RegexExecFlags flags = RegexExecFlags::None) -{ - ThreadedRegexVM vm{re}; - return vm.exec(begin, end, flags | RegexExecFlags::Search | RegexExecFlags::AnyMatch | RegexExecFlags::NoSaves); -} - -template -bool regex_search(It begin, It end, Vector& captures, const CompiledRegex& re, - RegexExecFlags flags = RegexExecFlags::None) -{ - ThreadedRegexVM vm{re}; - if (vm.exec(begin, end, flags | RegexExecFlags::Search)) - { - std::move(vm.captures().begin(), vm.captures().end(), std::back_inserter(captures)); - return true; - } - return false; -} - } #endif // regex_impl_hh_INCLUDED