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

Side by Side Diff: third_party/WebKit/Source/platform/Language.cpp

Issue 2615813003: Migrate WTF::Vector::append() to ::push_back() [part 14 of N] (Closed)
Patch Set: rebase, small fix in FontSettings.h Created 3 years, 11 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
1 /* 1 /*
2 * Copyright (C) 2010, 2013 Apple Inc. All rights reserved. 2 * Copyright (C) 2010, 2013 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 static Vector<AtomicString>& preferredLanguagesOverride() { 50 static Vector<AtomicString>& preferredLanguagesOverride() {
51 DEFINE_STATIC_LOCAL(Vector<AtomicString>, override, ()); 51 DEFINE_STATIC_LOCAL(Vector<AtomicString>, override, ());
52 return override; 52 return override;
53 } 53 }
54 54
55 void overrideUserPreferredLanguages(const Vector<AtomicString>& override) { 55 void overrideUserPreferredLanguages(const Vector<AtomicString>& override) {
56 Vector<AtomicString>& canonicalized = preferredLanguagesOverride(); 56 Vector<AtomicString>& canonicalized = preferredLanguagesOverride();
57 canonicalized.resize(0); 57 canonicalized.resize(0);
58 canonicalized.reserveCapacity(override.size()); 58 canonicalized.reserveCapacity(override.size());
59 for (const auto& lang : override) 59 for (const auto& lang : override)
60 canonicalized.append(canonicalizeLanguageIdentifier(lang)); 60 canonicalized.push_back(canonicalizeLanguageIdentifier(lang));
61 } 61 }
62 62
63 AtomicString defaultLanguage() { 63 AtomicString defaultLanguage() {
64 Vector<AtomicString>& override = preferredLanguagesOverride(); 64 Vector<AtomicString>& override = preferredLanguagesOverride();
65 if (!override.isEmpty()) 65 if (!override.isEmpty())
66 return override[0]; 66 return override[0];
67 return platformLanguage(); 67 return platformLanguage();
68 } 68 }
69 69
70 Vector<AtomicString> userPreferredLanguages() { 70 Vector<AtomicString> userPreferredLanguages() {
71 Vector<AtomicString>& override = preferredLanguagesOverride(); 71 Vector<AtomicString>& override = preferredLanguagesOverride();
72 if (!override.isEmpty()) 72 if (!override.isEmpty())
73 return override; 73 return override;
74 74
75 Vector<AtomicString> languages; 75 Vector<AtomicString> languages;
76 languages.reserveInitialCapacity(1); 76 languages.reserveInitialCapacity(1);
77 languages.append(platformLanguage()); 77 languages.push_back(platformLanguage());
78 return languages; 78 return languages;
79 } 79 }
80 80
81 size_t indexOfBestMatchingLanguageInList( 81 size_t indexOfBestMatchingLanguageInList(
82 const AtomicString& language, 82 const AtomicString& language,
83 const Vector<AtomicString>& languageList) { 83 const Vector<AtomicString>& languageList) {
84 AtomicString languageWithoutLocaleMatch; 84 AtomicString languageWithoutLocaleMatch;
85 AtomicString languageMatchButNotLocale; 85 AtomicString languageMatchButNotLocale;
86 size_t languageWithoutLocaleMatchIndex = 0; 86 size_t languageWithoutLocaleMatchIndex = 0;
87 size_t languageMatchButNotLocaleMatchIndex = 0; 87 size_t languageMatchButNotLocaleMatchIndex = 0;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 if (languageWithoutLocaleMatch.length()) 119 if (languageWithoutLocaleMatch.length())
120 return languageWithoutLocaleMatchIndex; 120 return languageWithoutLocaleMatchIndex;
121 121
122 if (languageMatchButNotLocale.length()) 122 if (languageMatchButNotLocale.length())
123 return languageMatchButNotLocaleMatchIndex; 123 return languageMatchButNotLocaleMatchIndex;
124 124
125 return languageList.size(); 125 return languageList.size();
126 } 126 }
127 127
128 } // namespace blink 128 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/FileChooser.cpp ('k') | third_party/WebKit/Source/platform/PODArena.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698