From 8cc9a44d47a729d2a22317ab5fb3432fcabd4861 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Sat, 9 Mar 2013 13:30:10 +0100 Subject: [PATCH] minor cleanups in complete_word --- src/input_handler.cc | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/input_handler.cc b/src/input_handler.cc index e7653152..6dc3f17a 100644 --- a/src/input_handler.cc +++ b/src/input_handler.cc @@ -463,14 +463,12 @@ static std::pair complete_word(const BufferIterat ++begin; const Buffer& buffer = pos.buffer(); - String prefix = buffer.string(begin, end); - String ex = "\\<\\Q" + prefix + "\\E\\w+\\>"; + String ex = R"(\<\Q)" + buffer.string(begin, end) + R"(\E\w+\>)"; Regex re(ex.begin(), ex.end()); - boost::regex_iterator it(buffer.begin(), buffer.end(), re); - boost::regex_iterator re_end; + using RegexIt = boost::regex_iterator; CandidateList result; - for (; it != re_end; ++it) + for (RegexIt it(buffer.begin(), buffer.end(), re), re_end; it != re_end; ++it) { auto& match = (*it)[0]; if (match.first <= pos and pos < match.second) @@ -481,7 +479,7 @@ static std::pair complete_word(const BufferIterat result.emplace_back(std::move(content)); } std::sort(result.begin(), result.end()); - return { result, begin }; + return { std::move(result), begin }; } class BufferCompleter