am f38969f3: Fix bug of dictionary dynamic updating methods.

* commit 'f38969f3f8a0684e43dbc7411873e90bc0bea3fe':
  Fix bug of dictionary dynamic updating methods.
main
Keisuke Kuroyanagi 2013-09-10 06:39:53 -07:00 committed by Android Git Automerger
commit 4be963a115
3 changed files with 5 additions and 5 deletions

View File

@ -59,9 +59,9 @@ class DynamicPatriciaTrieReadingUtils {
static AK_FORCE_INLINE NodeFlags updateAndGetFlags(const NodeFlags originalFlags, static AK_FORCE_INLINE NodeFlags updateAndGetFlags(const NodeFlags originalFlags,
const bool isMoved, const bool isDeleted) { const bool isMoved, const bool isDeleted) {
NodeFlags flags = originalFlags; NodeFlags flags = originalFlags;
flags = isMoved ? ((flags & (!MASK_MOVED)) | FLAG_IS_MOVED) : flags; flags = isMoved ? ((flags & (~MASK_MOVED)) | FLAG_IS_MOVED) : flags;
flags = isDeleted ? ((flags & (!MASK_MOVED)) | FLAG_IS_DELETED) : flags; flags = isDeleted ? ((flags & (~MASK_MOVED)) | FLAG_IS_DELETED) : flags;
flags = (!isMoved && !isDeleted) ? ((flags & (!MASK_MOVED)) | FLAG_IS_NOT_MOVED) : flags; flags = (!isMoved && !isDeleted) ? ((flags & (~MASK_MOVED)) | FLAG_IS_NOT_MOVED) : flags;
return flags; return flags;
} }

View File

@ -29,7 +29,7 @@ namespace latinime {
bool DynamicPatriciaTrieWritingHelper::addUnigramWord( bool DynamicPatriciaTrieWritingHelper::addUnigramWord(
DynamicPatriciaTrieReadingHelper *const readingHelper, DynamicPatriciaTrieReadingHelper *const readingHelper,
const int *const wordCodePoints, const int codePointCount, const int probability) { const int *const wordCodePoints, const int codePointCount, const int probability) {
int parentPos = NOT_A_VALID_WORD_POS; int parentPos = NOT_A_DICT_POS;
while (!readingHelper->isEnd()) { while (!readingHelper->isEnd()) {
const int matchedCodePointCount = readingHelper->getPrevTotalCodePointCount(); const int matchedCodePointCount = readingHelper->getPrevTotalCodePointCount();
if (!readingHelper->isMatchedCodePoint(0 /* index */, if (!readingHelper->isMatchedCodePoint(0 /* index */,

View File

@ -76,7 +76,7 @@ bool BufferWithExtendableBuffer::checkAndPrepareWriting(const int pos, const int
} }
} }
mUsedAdditionalBufferSize += size; mUsedAdditionalBufferSize += size;
} else if (pos + size >= tailPosition) { } else if (pos + size > tailPosition) {
// The access will beyond the tail of used region. // The access will beyond the tail of used region.
return false; return false;
} }