From c6eddefb0d2154855cb55e5264e6b974b6e90dbe Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Sat, 24 Jun 2017 12:24:24 +0100 Subject: Slight code refactoring and perf improvement in vector option to string --- src/string.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/string.cc') diff --git a/src/string.cc b/src/string.cc index 6fb64098..36beca1e 100644 --- a/src/string.cc +++ b/src/string.cc @@ -222,9 +222,10 @@ String escape(StringView str, StringView characters, char escape) { String res; res.reserve(str.length()); + auto cbeg = characters.begin(), cend = characters.end(); for (auto it = str.begin(), end = str.end(); it != end; ) { - auto next = std::find_if(it, end, [&characters](char c) { return contains(characters, c); }); + auto next = std::find_first_of(it, end, cbeg, cend); if (next != end) { res += StringView{it, next+1}; -- cgit v1.2.3