am e7ddf49d: Merge "Use emplace_back in getWordProperty()."

* commit 'e7ddf49d50bf6b97ffec9fcd78eea09c69f48763':
  Use emplace_back in getWordProperty().
main
Keisuke Kuroyanagi 2014-03-11 02:39:52 -07:00 committed by Android Git Automerger
commit d176932d0d
2 changed files with 11 additions and 12 deletions

View File

@ -349,14 +349,14 @@ const WordProperty PatriciaTriePolicy::getWordProperty(const int *const codePoin
// Skip the entry if the entry has been deleted. This never happens for ver2 dicts.
if (bigramsIt.getBigramPos() != NOT_A_DICT_POS) {
int word1Probability = NOT_A_PROBABILITY;
int word1CodePointCount = getCodePointsAndProbabilityAndReturnCodePointCount(
const int word1CodePointCount = getCodePointsAndProbabilityAndReturnCodePointCount(
bigramsIt.getBigramPos(), MAX_WORD_LENGTH, bigramWord1CodePoints,
&word1Probability);
std::vector<int> word1(bigramWord1CodePoints,
const std::vector<int> word1(bigramWord1CodePoints,
bigramWord1CodePoints + word1CodePointCount);
const int probability = getProbability(word1Probability, bigramsIt.getProbability());
bigrams.push_back(WordProperty::BigramProperty(&word1, probability,
NOT_A_TIMESTAMP /* timestamp */, 0 /* level */, 0 /* count */));
bigrams.emplace_back(&word1, probability,
NOT_A_TIMESTAMP /* timestamp */, 0 /* level */, 0 /* count */);
}
}
// Fetch shortcut information.
@ -372,12 +372,11 @@ const WordProperty PatriciaTriePolicy::getWordProperty(const int *const codePoin
hasNext = ShortcutListReadingUtils::hasNext(shortcutFlags);
const int shortcutTargetLength = ShortcutListReadingUtils::readShortcutTarget(
mDictRoot, MAX_WORD_LENGTH, shortcutTargetCodePoints, &shortcutPos);
std::vector<int> shortcutTarget(shortcutTargetCodePoints,
const std::vector<int> shortcutTarget(shortcutTargetCodePoints,
shortcutTargetCodePoints + shortcutTargetLength);
const int shortcutProbability =
ShortcutListReadingUtils::getProbabilityFromFlags(shortcutFlags);
shortcuts.push_back(
WordProperty::ShortcutProperty(&shortcutTarget, shortcutProbability));
shortcuts.emplace_back(&shortcutTarget, shortcutProbability);
}
}
return WordProperty(&codePointVector, ptNodeParams.isNotAWord(),

View File

@ -382,16 +382,16 @@ const WordProperty Ver4PatriciaTriePolicy::getWordProperty(const int *const code
const int codePointCount = getCodePointsAndProbabilityAndReturnCodePointCount(
word1TerminalPtNodePos, MAX_WORD_LENGTH, bigramWord1CodePoints,
&word1Probability);
std::vector<int> word1(bigramWord1CodePoints,
const std::vector<int> word1(bigramWord1CodePoints,
bigramWord1CodePoints + codePointCount);
const HistoricalInfo *const historicalInfo = bigramEntry.getHistoricalInfo();
const int probability = bigramEntry.hasHistoricalInfo() ?
ForgettingCurveUtils::decodeProbability(
bigramEntry.getHistoricalInfo(), mHeaderPolicy) :
getProbability(word1Probability, bigramEntry.getProbability());
bigrams.push_back(WordProperty::BigramProperty(&word1, probability,
bigrams.emplace_back(&word1, probability,
historicalInfo->getTimeStamp(), historicalInfo->getLevel(),
historicalInfo->getCount()));
historicalInfo->getCount());
}
}
// Fetch shortcut information.
@ -407,8 +407,8 @@ const WordProperty Ver4PatriciaTriePolicy::getWordProperty(const int *const code
int shortcutProbability = NOT_A_PROBABILITY;
shortcutDictContent->getShortcutEntryAndAdvancePosition(MAX_WORD_LENGTH, shortcutTarget,
&shortcutTargetLength, &shortcutProbability, &hasNext, &shortcutPos);
std::vector<int> target(shortcutTarget, shortcutTarget + shortcutTargetLength);
shortcuts.push_back(WordProperty::ShortcutProperty(&target, shortcutProbability));
const std::vector<int> target(shortcutTarget, shortcutTarget + shortcutTargetLength);
shortcuts.emplace_back(&target, shortcutProbability);
}
}
return WordProperty(&codePointVector, ptNodeParams.isNotAWord(),