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

Side by Side Diff: chromeos/ime/extension_ime_util.cc

Issue 457943002: Improve perforance for component IME extensions initialization by using map instead of vector in Co… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: changed solution, test green. 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chromeos/ime/extension_ime_util.h" 5 #include "chromeos/ime/extension_ime_util.h"
6 6
7 #include "base/strings/string_util.h" 7 #include "base/strings/string_util.h"
8 8
9 namespace chromeos { 9 namespace chromeos {
10 10
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 if (IsComponentExtensionIME(input_method_id) && 48 if (IsComponentExtensionIME(input_method_id) &&
49 input_method_id.size() >= kComponentExtensionIMEPrefixLength + 49 input_method_id.size() >= kComponentExtensionIMEPrefixLength +
50 kExtensionIdLength) { 50 kExtensionIdLength) {
51 return input_method_id.substr(kComponentExtensionIMEPrefixLength, 51 return input_method_id.substr(kComponentExtensionIMEPrefixLength,
52 kExtensionIdLength); 52 kExtensionIdLength);
53 } 53 }
54 return ""; 54 return "";
55 } 55 }
56 56
57 std::string GetComponentIDByInputMethodID(const std::string& input_method_id) { 57 std::string GetComponentIDByInputMethodID(const std::string& input_method_id) {
58 if (IsComponentExtensionIME(input_method_id)) 58 if (IsComponentExtensionIME(input_method_id) &&
59 input_method_id.size() >= kComponentExtensionIMEPrefixLength +
Seigo Nonaka 2014/08/11 16:41:06 Is this check necessary? If so, how about moving t
Shu Chen 2014/08/12 04:44:06 Done.
60 kExtensionIdLength)
59 return input_method_id.substr(kComponentExtensionIMEPrefixLength + 61 return input_method_id.substr(kComponentExtensionIMEPrefixLength +
60 kExtensionIdLength); 62 kExtensionIdLength);
61 if (IsExtensionIME(input_method_id)) 63 if (IsExtensionIME(input_method_id) &&
64 input_method_id.size() >= kExtensionIMEPrefixLength +
Seigo Nonaka 2014/08/11 16:41:06 same as above.
Shu Chen 2014/08/12 04:44:07 Done.
65 kExtensionIdLength)
62 return input_method_id.substr(kExtensionIMEPrefixLength + 66 return input_method_id.substr(kExtensionIMEPrefixLength +
63 kExtensionIdLength); 67 kExtensionIdLength);
64 return input_method_id; 68 return input_method_id;
65 } 69 }
66 70
67 std::string GetInputMethodIDByEngineID(const std::string& engine_id) { 71 std::string GetInputMethodIDByEngineID(const std::string& engine_id) {
68 if (StartsWithASCII(engine_id, kComponentExtensionIMEPrefix, true) || 72 if (StartsWithASCII(engine_id, kComponentExtensionIMEPrefix, true) ||
69 StartsWithASCII(engine_id, kExtensionIMEPrefix, true)) { 73 StartsWithASCII(engine_id, kExtensionIMEPrefix, true)) {
70 return engine_id; 74 return engine_id;
71 } 75 }
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 } 125 }
122 126
123 std::string MaybeGetLegacyXkbId(const std::string& input_method_id) { 127 std::string MaybeGetLegacyXkbId(const std::string& input_method_id) {
124 if (IsKeyboardLayoutExtension(input_method_id)) 128 if (IsKeyboardLayoutExtension(input_method_id))
125 return GetComponentIDByInputMethodID(input_method_id); 129 return GetComponentIDByInputMethodID(input_method_id);
126 return input_method_id; 130 return input_method_id;
127 } 131 }
128 132
129 } // namespace extension_ime_util 133 } // namespace extension_ime_util
130 } // namespace chromeos 134 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698