aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChih-Hung Hsieh <chh@google.com>2018-12-11 16:20:39 -0800
committerandroid-build-merger <android-build-merger@google.com>2018-12-11 16:20:39 -0800
commit535cd61e636abbda6014ab0f48f65b264114dcac (patch)
tree7fe905ed76e2d644cec292b875a2bae6cb39eae3
parent6c06f060794cc6e9d7ccf0a4e35a60adfe479da1 (diff)
parent947f8ee063d8fa476080e61ef3e598f4f656d379 (diff)
downloadlatinime-535cd61e636abbda6014ab0f48f65b264114dcac.tar.gz
latinime-535cd61e636abbda6014ab0f48f65b264114dcac.tar.xz
latinime-535cd61e636abbda6014ab0f48f65b264114dcac.zip
Merge "Fix performance-for-range-copy warnings" am: db2e4888f8
am: 947f8ee063 Change-Id: I153c9732d7fd1733f196b9807d99cfe59fcde012
-rw-r--r--native/dicttoolkit/src/offdevice_intermediate_dict/offdevice_intermediate_dict.cpp2
-rw-r--r--native/jni/src/dictionary/structure/v4/ver4_patricia_trie_policy.cpp4
-rw-r--r--native/jni/tests/dictionary/structure/v4/content/language_model_dict_content_test.cpp2
3 files changed, 4 insertions, 4 deletions
diff --git a/native/dicttoolkit/src/offdevice_intermediate_dict/offdevice_intermediate_dict.cpp b/native/dicttoolkit/src/offdevice_intermediate_dict/offdevice_intermediate_dict.cpp
index af28131cf..e94a9c2ff 100644
--- a/native/dicttoolkit/src/offdevice_intermediate_dict/offdevice_intermediate_dict.cpp
+++ b/native/dicttoolkit/src/offdevice_intermediate_dict/offdevice_intermediate_dict.cpp
@@ -93,7 +93,7 @@ const WordProperty *OffdeviceIntermediateDict::getWordProperty(
const OffdeviceIntermediateDictPtNodeArray *ptNodeArray = &mRootPtNodeArray;
for (size_t i = 0; i < codePoints.size();) {
bool foundNext = false;
- for (const auto ptNode : ptNodeArray->getPtNodeList()) {
+ for (const auto& ptNode : ptNodeArray->getPtNodeList()) {
const CodePointArrayView ptNodeCodePoints = ptNode->getPtNodeCodePoints();
if (codePoints[i] < ptNodeCodePoints[0]) {
continue;
diff --git a/native/jni/src/dictionary/structure/v4/ver4_patricia_trie_policy.cpp b/native/jni/src/dictionary/structure/v4/ver4_patricia_trie_policy.cpp
index 1dbec5545..6f96a5a0b 100644
--- a/native/jni/src/dictionary/structure/v4/ver4_patricia_trie_policy.cpp
+++ b/native/jni/src/dictionary/structure/v4/ver4_patricia_trie_policy.cpp
@@ -141,7 +141,7 @@ void Ver4PatriciaTriePolicy::iterateNgramEntries(const WordIdArrayView prevWordI
}
const auto languageModelDictContent = mBuffers->getLanguageModelDictContent();
for (size_t i = 1; i <= prevWordIds.size(); ++i) {
- for (const auto entry : languageModelDictContent->getProbabilityEntries(
+ for (const auto& entry : languageModelDictContent->getProbabilityEntries(
prevWordIds.limit(i))) {
const ProbabilityEntry &probabilityEntry = entry.getProbabilityEntry();
if (!probabilityEntry.isValid()) {
@@ -516,7 +516,7 @@ const WordProperty Ver4PatriciaTriePolicy::getWordProperty(
int ngramPrevWordsCodePoints[MAX_PREV_WORD_COUNT_FOR_N_GRAM][MAX_WORD_LENGTH];
int ngramPrevWordsCodePointCount[MAX_PREV_WORD_COUNT_FOR_N_GRAM];
bool ngramPrevWordIsBeginningOfSentense[MAX_PREV_WORD_COUNT_FOR_N_GRAM];
- for (const auto entry : languageModelDictContent->exportAllNgramEntriesRelatedToWord(
+ for (const auto& entry : languageModelDictContent->exportAllNgramEntriesRelatedToWord(
mHeaderPolicy, wordId)) {
const int codePointCount = getCodePointsAndReturnCodePointCount(entry.getTargetWordId(),
MAX_WORD_LENGTH, ngramTargetCodePoints);
diff --git a/native/jni/tests/dictionary/structure/v4/content/language_model_dict_content_test.cpp b/native/jni/tests/dictionary/structure/v4/content/language_model_dict_content_test.cpp
index ca8626e2f..ab11975c2 100644
--- a/native/jni/tests/dictionary/structure/v4/content/language_model_dict_content_test.cpp
+++ b/native/jni/tests/dictionary/structure/v4/content/language_model_dict_content_test.cpp
@@ -80,7 +80,7 @@ TEST(LanguageModelDictContentTest, TestIterateProbabilityEntry) {
languageModelDictContent.setProbabilityEntry(wordId, &originalEntry);
}
std::unordered_set<int> wordIdSet(std::begin(wordIds), std::end(wordIds));
- for (const auto entry : languageModelDictContent.getProbabilityEntries(WordIdArrayView())) {
+ for (const auto& entry : languageModelDictContent.getProbabilityEntries(WordIdArrayView())) {
EXPECT_EQ(originalEntry.getFlags(), entry.getProbabilityEntry().getFlags());
EXPECT_EQ(originalEntry.getProbability(), entry.getProbabilityEntry().getProbability());
wordIdSet.erase(entry.getWordId());