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 af28131cfbba19608e2a79892ed14a3d89148e5c..e94a9c2ffc95c64641452d42a19be9748c5a17e6 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 1dbec55454af05421e14cbd3b717a1ffc6a0abc8..6f96a5a0bfa8d082d448532f095cb858b6e5ecac 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 ca8626e2fc84a310c9c79c19dd6bec1289735cff..ab11975c24b483e278b4d5285d25d4b10a69ee36 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());