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

Unified Diff: ui/base/l10n/l10n_util_collator.h

Issue 518533002: Move StringComparator<string16>::operator() to header (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/base/l10n/l10n_util.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/base/l10n/l10n_util_collator.h
diff --git a/ui/base/l10n/l10n_util_collator.h b/ui/base/l10n/l10n_util_collator.h
index e1b91abd14ace5408c523f11600c22a0d9962792..f364e5c1b8c3f7d21abca8a04e6f425ab5a7b329 100644
--- a/ui/base/l10n/l10n_util_collator.h
+++ b/ui/base/l10n/l10n_util_collator.h
@@ -106,9 +106,17 @@ class StringComparator : public std::binary_function<const Element&,
};
// Specialization of operator() method for base::string16 version.
-template <> UI_BASE_EXPORT
-bool StringComparator<base::string16>::operator()(const base::string16& lhs,
- const base::string16& rhs);
+template <>
+UI_BASE_EXPORT inline bool StringComparator<base::string16>::operator()(
+ const base::string16& lhs,
+ const base::string16& rhs) {
+ // If we can not get collator instance for specified locale, just do simple
+ // string compare.
+ if (!collator_)
+ return lhs < rhs;
+ return base::i18n::CompareString16WithCollator(collator_, lhs, rhs) ==
+ UCOL_LESS;
+}
// In place sorting of |elements| of a vector according to the string key of
// each element in the vector by using collation rules for |locale|.
« no previous file with comments | « ui/base/l10n/l10n_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698