From ea4788da28f8f2053fbc8881e115336bc6e471f7 Mon Sep 17 00:00:00 2001 From: Anatoly Serdtcev Date: Thu, 7 Mar 2019 13:54:37 +0300 Subject: [PATCH 1/2] =?UTF-8?q?[geocoder]=20Add=20shuffle=20match=20('?= =?UTF-8?q?=D0=90=D1=8D=D1=80=D0=BE=D0=BF=D0=BE=D1=80=D1=82=D0=BE=D0=B2?= =?UTF-8?q?=D1=81=D0=BA=D0=B0=D1=8F=201-=D1=8F'=20and=20'1-=D1=8F=20=D0=90?= =?UTF-8?q?=D1=8D=D1=80=D0=BE=D0=BF=D0=BE=D1=80=D1=82=D0=BE=D0=B2=D1=81?= =?UTF-8?q?=D0=BA=D0=B0=D1=8F')?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- geocoder/index.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/geocoder/index.cpp b/geocoder/index.cpp index 21b30be043..acf9b1e5e6 100644 --- a/geocoder/index.cpp +++ b/geocoder/index.cpp @@ -8,6 +8,7 @@ #include "base/logging.hpp" #include "base/string_utils.hpp" +#include #include #include #include @@ -43,7 +44,12 @@ Index::Doc const & Index::GetDoc(DocId const id) const // static string Index::MakeIndexKey(Tokens const & tokens) { - return strings::JoinStrings(tokens, " "); + if (tokens.size() == 1 || std::is_sorted(begin(tokens), end(tokens))) + return strings::JoinStrings(tokens, " "); + + auto indexTokens = tokens; + std::sort(begin(indexTokens), end(indexTokens)); + return strings::JoinStrings(indexTokens, " "); } void Index::AddEntries() From ef46d61e474c6075e4765b3fffc39a661946417d Mon Sep 17 00:00:00 2001 From: Anatoly Serdtcev Date: Thu, 7 Mar 2019 16:13:36 +0300 Subject: [PATCH 2/2] [geocoder] Fix for review --- geocoder/index.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/geocoder/index.cpp b/geocoder/index.cpp index acf9b1e5e6..80142569e7 100644 --- a/geocoder/index.cpp +++ b/geocoder/index.cpp @@ -44,11 +44,11 @@ Index::Doc const & Index::GetDoc(DocId const id) const // static string Index::MakeIndexKey(Tokens const & tokens) { - if (tokens.size() == 1 || std::is_sorted(begin(tokens), end(tokens))) + if (tokens.size() == 1 || is_sorted(begin(tokens), end(tokens))) return strings::JoinStrings(tokens, " "); auto indexTokens = tokens; - std::sort(begin(indexTokens), end(indexTokens)); + sort(begin(indexTokens), end(indexTokens)); return strings::JoinStrings(indexTokens, " "); }