Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(400)

Side by Side Diff: components/omnibox/browser/shortcut_match.cc

Issue 1877833002: Optimize shortcuts provider (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixes after review, round 1 Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "components/omnibox/browser/shortcut_match.h"
6
7 #include <algorithm>
8
9 ShortcutMatch::ShortcutMatch(int relevance,
10 const GURL& stripped_destination_url,
11 const ShortcutsDatabase::Shortcut* shortcut) :
12 relevance(relevance),
13 stripped_destination_url(stripped_destination_url),
14 shortcut(shortcut),
15 contents(shortcut->match_core.contents),
16 type(static_cast<AutocompleteMatch::Type>(shortcut->match_core.type)) {}
17
18 // static
19 bool ShortcutMatch::DestinationsEqual(const ShortcutMatch& elem1,
20 const ShortcutMatch& elem2) {
21 if (elem1.stripped_destination_url.is_empty() &&
22 elem2.stripped_destination_url.is_empty())
23 return false;
24 return elem1.stripped_destination_url == elem2.stripped_destination_url;
Peter Kasting 2016/04/12 23:29:50 Nit: Simpler: return (elem1.stripped_destinatio
Alexander Yashkin 2016/04/13 09:29:36 Replaced here and in autocomplete_match.cc with
25 }
26
27 // static
28 bool ShortcutMatch::MoreRelevant(const ShortcutMatch& elem1,
29 const ShortcutMatch& elem2) {
30 // For equal-relevance matches, we sort alphabetically, so that providers
31 // who return multiple elements at the same priority get a "stable" sort
32 // across multiple updates.
33 return (elem1.relevance == elem2.relevance) ?
34 (elem1.contents < elem2.contents) : (elem1.relevance > elem2.relevance);
35 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698