MCPcopy Create free account
hub / github.com/comaps/comaps / Add

Method Add

libs/search/query_saver.cpp:72–95  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

70}
71
72void QuerySaver::Add(SearchRequest const & query)
73{
74 // This change was made just before release, so we don't use untested search normalization methods.
75 // TODO (ldragunov) Rewrite to normalized requests.
76 SearchRequest trimmedQuery(query);
77 strings::Trim(trimmedQuery.first);
78 strings::Trim(trimmedQuery.second);
79 auto trimmedComparator = [&trimmedQuery](SearchRequest request)
80 {
81 strings::Trim(request.first);
82 strings::Trim(request.second);
83 return trimmedQuery == request;
84 };
85 // Remove items if needed.
86 auto const it = find_if(m_topQueries.begin(), m_topQueries.end(), trimmedComparator);
87 if (it != m_topQueries.end())
88 m_topQueries.erase(it);
89 else if (m_topQueries.size() >= kMaxSuggestionsCount)
90 m_topQueries.pop_back();
91
92 // Add new query and save it to drive.
93 m_topQueries.push_front(query);
94 Save();
95}
96
97void QuerySaver::Clear()
98{

Callers 15

MatchMethod · 0.45
ProcessorMethod · 0.45
OnBookmarksCreatedMethod · 0.45
SearchPostcodeMethod · 0.45
MatchCitiesMethod · 0.45
MatchAroundPivotMethod · 0.45
WithPostcodesMethod · 0.45
StringsMatcherMethod · 0.45
HouseNumberClassifierMethod · 0.45
GetDocVecsMethod · 0.45
CategoriesCacheMethod · 0.45

Calls 7

TrimFunction · 0.85
SaveFunction · 0.50
beginMethod · 0.45
endMethod · 0.45
eraseMethod · 0.45
sizeMethod · 0.45
pop_backMethod · 0.45

Tested by

no test coverage detected