mirror of
https://github.com/mii443/mozc.git
synced 2025-08-22 16:15:46 +00:00
Address clang-tidy warning.
This is performance lint, which is useless in tests, but let's burn it. Also, slightly updated the code to make it look more pretty (and that's how I silenced the lint). PiperOrigin-RevId: 727725125
This commit is contained in:
committed by
Hiroyuki Komatsu
parent
4c86252df2
commit
080eddd316
@ -28,6 +28,7 @@
|
|||||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <array>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
@ -45,6 +46,7 @@
|
|||||||
#include "absl/algorithm/container.h"
|
#include "absl/algorithm/container.h"
|
||||||
#include "absl/flags/flag.h"
|
#include "absl/flags/flag.h"
|
||||||
#include "absl/log/check.h"
|
#include "absl/log/check.h"
|
||||||
|
#include "absl/strings/str_cat.h"
|
||||||
#include "absl/strings/str_format.h"
|
#include "absl/strings/str_format.h"
|
||||||
#include "absl/strings/string_view.h"
|
#include "absl/strings/string_view.h"
|
||||||
#include "absl/time/time.h"
|
#include "absl/time/time.h"
|
||||||
@ -245,25 +247,24 @@ void CreatePredictionKeys(PredictionRequestType type,
|
|||||||
CHECK(request_keys);
|
CHECK(request_keys);
|
||||||
request_keys->clear();
|
request_keys->clear();
|
||||||
|
|
||||||
const char *kVoels[] = {"a", "i", "u", "e", "o"};
|
constexpr std::array<absl::string_view, 5> kVoels = {"a", "i", "u", "e", "o"};
|
||||||
const char *kConsonant[] = {"k", "s", "t", "n", "h", "m", "y", "r", "w"};
|
constexpr std::array<absl::string_view, 10> kConsonants = {
|
||||||
std::vector<std::string> one_chars;
|
"", "k", "s", "t", "n", "h", "m", "y", "r", "w"};
|
||||||
for (size_t i = 0; i < std::size(kVoels); ++i) {
|
|
||||||
one_chars.push_back(kVoels[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (size_t i = 0; i < std::size(kConsonant); ++i) {
|
std::vector<std::string> one_chars;
|
||||||
for (size_t j = 0; j < std::size(kVoels); ++j) {
|
for (absl::string_view c : kConsonants) {
|
||||||
one_chars.push_back(std::string(kConsonant[i]) + std::string(kVoels[j]));
|
for (absl::string_view v : kVoels) {
|
||||||
|
one_chars.push_back(absl::StrCat(c, v));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> two_chars;
|
std::vector<std::string> two_chars;
|
||||||
for (size_t i = 0; i < one_chars.size(); ++i) {
|
for (absl::string_view c1 : one_chars) {
|
||||||
for (size_t j = 0; j < one_chars.size(); ++j) {
|
for (absl::string_view c2 : one_chars) {
|
||||||
two_chars.push_back(one_chars[i] + one_chars[j]);
|
two_chars.push_back(absl::StrCat(c1, c2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case ONE_CHAR:
|
case ONE_CHAR:
|
||||||
std::copy(one_chars.begin(), one_chars.end(),
|
std::copy(one_chars.begin(), one_chars.end(),
|
||||||
|
Reference in New Issue
Block a user