Chromium Code Reviews| Index: chrome/browser/chromeos/input_method/input_method_manager_impl.cc |
| diff --git a/chrome/browser/chromeos/input_method/input_method_manager_impl.cc b/chrome/browser/chromeos/input_method/input_method_manager_impl.cc |
| index bff428cf90affa2c97936a29952c3c3809a76663..2bc7a784cb87168f6cbc60a0b308b3253f623e76 100644 |
| --- a/chrome/browser/chromeos/input_method/input_method_manager_impl.cc |
| +++ b/chrome/browser/chromeos/input_method/input_method_manager_impl.cc |
| @@ -10,6 +10,7 @@ |
| #include "base/basictypes.h" |
| #include "base/bind.h" |
| +#include "base/hash.h" |
| #include "base/location.h" |
| #include "base/memory/scoped_ptr.h" |
| #include "base/metrics/histogram.h" |
| @@ -863,22 +864,10 @@ InputMethodManagerImpl::InputMethodManagerImpl( |
| util_.ResetInputMethods(descriptors); |
| // Initializes the stat id map. |
| - std::map<int, std::vector<std::string> > buckets; |
| for (InputMethodDescriptors::const_iterator it = descriptors.begin(); |
| it != descriptors.end(); ++it) { |
| - char first_char; |
| - int cat_id = static_cast<int>( |
| - GetInputMethodCategory(it->id(), &first_char)); |
| - int key = cat_id * 1000 + first_char; |
| - buckets[key].push_back(it->id()); |
| - } |
| - for (std::map<int, std::vector<std::string>>::iterator i = |
| - buckets.begin(); i != buckets.end(); ++i) { |
| - std::sort(i->second.begin(), i->second.end()); |
| - for (size_t j = 0; j < i->second.size() && j < 100; ++j) { |
| - int key = i->first * 100 + j; |
| - stat_id_map_[i->second[j]] = key; |
| - } |
| + std::string id = it->id(); |
| + stat_id_map_[id] = (int)base::SuperFastHash(id.c_str(), id.length()); |
|
Seigo Nonaka
2015/07/16 08:24:47
nit: please use static_cast<int>
Shu Chen
2015/07/16 08:57:27
Done.
|
| } |
| } |
| @@ -892,8 +881,7 @@ void InputMethodManagerImpl::RecordInputMethodUsage( |
| UMA_HISTOGRAM_ENUMERATION("InputMethod.Category", |
| GetInputMethodCategory(input_method_id), |
| INPUT_METHOD_CATEGORY_MAX); |
| - UMA_HISTOGRAM_SPARSE_SLOWLY("InputMethod.ID", |
| - stat_id_map_[input_method_id]); |
| + UMA_HISTOGRAM_SPARSE_SLOWLY("InputMethod.ID2", stat_id_map_[input_method_id]); |
| } |
| void InputMethodManagerImpl::AddObserver( |