Merge "Use nullptr instead of 0 for pointers."

main
Keisuke Kuroyanagi 2014-03-07 03:56:56 +00:00 committed by Android (Google) Code Review
commit 3339224813
11 changed files with 28 additions and 26 deletions

View File

@ -161,7 +161,7 @@ static int latinime_BinaryDictionary_getSuggestions(JNIEnv *env, jclass clazz, j
const jsize prevWordCodePointsLength = const jsize prevWordCodePointsLength =
prevWordCodePointsForBigrams ? env->GetArrayLength(prevWordCodePointsForBigrams) : 0; prevWordCodePointsForBigrams ? env->GetArrayLength(prevWordCodePointsForBigrams) : 0;
int prevWordCodePointsInternal[prevWordCodePointsLength]; int prevWordCodePointsInternal[prevWordCodePointsLength];
int *prevWordCodePoints = 0; int *prevWordCodePoints = nullptr;
env->GetIntArrayRegion(xCoordinatesArray, 0, inputSize, xCoordinates); env->GetIntArrayRegion(xCoordinatesArray, 0, inputSize, xCoordinates);
env->GetIntArrayRegion(yCoordinatesArray, 0, inputSize, yCoordinates); env->GetIntArrayRegion(yCoordinatesArray, 0, inputSize, yCoordinates);
env->GetIntArrayRegion(timesArray, 0, inputSize, times); env->GetIntArrayRegion(timesArray, 0, inputSize, times);

View File

@ -25,7 +25,7 @@ DicNode::DicNode(const DicNode &dicNode)
#endif #endif
mDicNodeProperties(dicNode.mDicNodeProperties), mDicNodeState(dicNode.mDicNodeState), mDicNodeProperties(dicNode.mDicNodeProperties), mDicNodeState(dicNode.mDicNodeState),
mIsCachedForNextSuggestion(dicNode.mIsCachedForNextSuggestion), mIsUsed(dicNode.mIsUsed), mIsCachedForNextSuggestion(dicNode.mIsCachedForNextSuggestion), mIsUsed(dicNode.mIsUsed),
mReleaseListener(0) { mReleaseListener(nullptr) {
/* empty */ /* empty */
} }

View File

@ -93,7 +93,7 @@ class DicNode {
mProfiler(), mProfiler(),
#endif #endif
mDicNodeProperties(), mDicNodeState(), mIsCachedForNextSuggestion(false), mDicNodeProperties(), mDicNodeState(), mIsCachedForNextSuggestion(false),
mIsUsed(false), mReleaseListener(0) {} mIsUsed(false), mReleaseListener(nullptr) {}
DicNode(const DicNode &dicNode); DicNode(const DicNode &dicNode);
DicNode &operator=(const DicNode &dicNode); DicNode &operator=(const DicNode &dicNode);

View File

@ -84,7 +84,7 @@ const DigraphUtils::DigraphType DigraphUtils::USED_DIGRAPH_TYPES[] =
} }
/** /**
* Returns the digraph for the input composite glyph codepoint, or 0 if none exists. * Returns the digraph for the input composite glyph codepoint, or nullptr if none exists.
* compositeGlyphCodePoint: the method returns the digraph corresponding to this codepoint. * compositeGlyphCodePoint: the method returns the digraph corresponding to this codepoint.
*/ */
/* static */ const DigraphUtils::digraph_t *DigraphUtils::getDigraphForCodePoint( /* static */ const DigraphUtils::digraph_t *DigraphUtils::getDigraphForCodePoint(
@ -96,17 +96,17 @@ const DigraphUtils::DigraphType DigraphUtils::USED_DIGRAPH_TYPES[] =
return digraph; return digraph;
} }
} }
return 0; return nullptr;
} }
/** /**
* Returns the digraph for the input composite glyph codepoint, or 0 if none exists. * Returns the digraph for the input composite glyph codepoint, or nullptr if none exists.
* digraphType: the type of digraphs supported. * digraphType: the type of digraphs supported.
* compositeGlyphCodePoint: the method returns the digraph corresponding to this codepoint. * compositeGlyphCodePoint: the method returns the digraph corresponding to this codepoint.
*/ */
/* static */ const DigraphUtils::digraph_t *DigraphUtils::getDigraphForDigraphTypeAndCodePoint( /* static */ const DigraphUtils::digraph_t *DigraphUtils::getDigraphForDigraphTypeAndCodePoint(
const DigraphUtils::DigraphType digraphType, const int compositeGlyphCodePoint) { const DigraphUtils::DigraphType digraphType, const int compositeGlyphCodePoint) {
const DigraphUtils::digraph_t *digraphs = 0; const DigraphUtils::digraph_t *digraphs = nullptr;
const int compositeGlyphLowerCodePoint = CharUtils::toLowerCase(compositeGlyphCodePoint); const int compositeGlyphLowerCodePoint = CharUtils::toLowerCase(compositeGlyphCodePoint);
const int digraphsSize = const int digraphsSize =
DigraphUtils::getAllDigraphsForDigraphTypeAndReturnSize(digraphType, &digraphs); DigraphUtils::getAllDigraphsForDigraphTypeAndReturnSize(digraphType, &digraphs);
@ -115,7 +115,7 @@ const DigraphUtils::DigraphType DigraphUtils::USED_DIGRAPH_TYPES[] =
return &digraphs[i]; return &digraphs[i];
} }
} }
return 0; return nullptr;
} }
} // namespace latinime } // namespace latinime

View File

@ -43,7 +43,7 @@ class ProximityInfoState {
// Defined here // // Defined here //
///////////////////////////////////////// /////////////////////////////////////////
AK_FORCE_INLINE ProximityInfoState() AK_FORCE_INLINE ProximityInfoState()
: mProximityInfo(0), mMaxPointToKeyLength(0.0f), mAverageSpeed(0.0f), : mProximityInfo(nullptr), mMaxPointToKeyLength(0.0f), mAverageSpeed(0.0f),
mHasTouchPositionCorrectionData(false), mMostCommonKeyWidthSquare(0), mHasTouchPositionCorrectionData(false), mMostCommonKeyWidthSquare(0),
mKeyCount(0), mCellHeight(0), mCellWidth(0), mGridHeight(0), mGridWidth(0), mKeyCount(0), mCellHeight(0), mCellWidth(0), mGridHeight(0), mGridWidth(0),
mIsContinuousSuggestionPossible(false), mHasBeenUpdatedByGeometricInput(false), mIsContinuousSuggestionPossible(false), mHasBeenUpdatedByGeometricInput(false),

View File

@ -59,8 +59,8 @@ class DicTraverseSession {
} }
AK_FORCE_INLINE DicTraverseSession(JNIEnv *env, jstring localeStr, bool usesLargeCache) AK_FORCE_INLINE DicTraverseSession(JNIEnv *env, jstring localeStr, bool usesLargeCache)
: mPrevWordPtNodePos(NOT_A_DICT_POS), mProximityInfo(0), : mPrevWordPtNodePos(NOT_A_DICT_POS), mProximityInfo(nullptr),
mDictionary(0), mSuggestOptions(0), mDicNodesCache(usesLargeCache), mDictionary(nullptr), mSuggestOptions(nullptr), mDicNodesCache(usesLargeCache),
mMultiBigramMap(), mInputSize(0), mPartiallyCommited(false), mMaxPointerCount(1), mMultiBigramMap(), mInputSize(0), mPartiallyCommited(false), mMaxPointerCount(1),
mMultiWordCostMultiplier(1.0f) { mMultiWordCostMultiplier(1.0f) {
// NOTE: mProximityInfoStates is an array of instances. // NOTE: mProximityInfoStates is an array of instances.

View File

@ -42,9 +42,9 @@ class Weighting;
class Suggest : public SuggestInterface { class Suggest : public SuggestInterface {
public: public:
AK_FORCE_INLINE Suggest(const SuggestPolicy *const suggestPolicy) AK_FORCE_INLINE Suggest(const SuggestPolicy *const suggestPolicy)
: TRAVERSAL(suggestPolicy ? suggestPolicy->getTraversal() : 0), : TRAVERSAL(suggestPolicy ? suggestPolicy->getTraversal() : nullptr),
SCORING(suggestPolicy ? suggestPolicy->getScoring() : 0), SCORING(suggestPolicy ? suggestPolicy->getScoring() : nullptr),
WEIGHTING(suggestPolicy ? suggestPolicy->getWeighting() : 0) {} WEIGHTING(suggestPolicy ? suggestPolicy->getWeighting() : nullptr) {}
AK_FORCE_INLINE virtual ~Suggest() {} AK_FORCE_INLINE virtual ~Suggest() {}
int getSuggestions(ProximityInfo *pInfo, void *traverseSession, int *inputXs, int *inputYs, int getSuggestions(ProximityInfo *pInfo, void *traverseSession, int *inputXs, int *inputYs,
int *times, int *pointerIds, int *inputCodePoints, int inputSize, int commitPoint, int *times, int *pointerIds, int *inputCodePoints, int inputSize, int commitPoint,

View File

@ -31,10 +31,11 @@ class SingleDictContent : public DictContent {
SingleDictContent(const char *const dictPath, const char *const contentFileName, SingleDictContent(const char *const dictPath, const char *const contentFileName,
const bool isUpdatable) const bool isUpdatable)
: mMmappedBuffer(MmappedBuffer::openBuffer(dictPath, contentFileName, isUpdatable)), : mMmappedBuffer(MmappedBuffer::openBuffer(dictPath, contentFileName, isUpdatable)),
mExpandableContentBuffer(mMmappedBuffer.get() ? mMmappedBuffer.get()->getBuffer() : 0, mExpandableContentBuffer(mMmappedBuffer.get() ?
mMmappedBuffer.get()->getBuffer() : nullptr,
mMmappedBuffer.get() ? mMmappedBuffer.get()->getBufferSize() : 0, mMmappedBuffer.get() ? mMmappedBuffer.get()->getBufferSize() : 0,
BufferWithExtendableBuffer::DEFAULT_MAX_ADDITIONAL_BUFFER_SIZE), BufferWithExtendableBuffer::DEFAULT_MAX_ADDITIONAL_BUFFER_SIZE),
mIsValid(mMmappedBuffer.get() != 0) {} mIsValid(mMmappedBuffer.get()) {}
SingleDictContent() SingleDictContent()
: mMmappedBuffer(0), mExpandableContentBuffer(Ver4DictConstants::MAX_DICTIONARY_SIZE), : mMmappedBuffer(0), mExpandableContentBuffer(Ver4DictConstants::MAX_DICTIONARY_SIZE),

View File

@ -40,20 +40,21 @@ class SparseTableDictContent : public DictContent {
MmappedBuffer::openBuffer(dictPath, addressTableFileName, isUpdatable)), MmappedBuffer::openBuffer(dictPath, addressTableFileName, isUpdatable)),
mContentBuffer(MmappedBuffer::openBuffer(dictPath, contentFileName, isUpdatable)), mContentBuffer(MmappedBuffer::openBuffer(dictPath, contentFileName, isUpdatable)),
mExpandableLookupTableBuffer( mExpandableLookupTableBuffer(
mLookupTableBuffer.get() ? mLookupTableBuffer.get()->getBuffer() : 0, mLookupTableBuffer.get() ? mLookupTableBuffer.get()->getBuffer() : nullptr,
mLookupTableBuffer.get() ? mLookupTableBuffer.get()->getBufferSize() : 0, mLookupTableBuffer.get() ? mLookupTableBuffer.get()->getBufferSize() : 0,
BufferWithExtendableBuffer::DEFAULT_MAX_ADDITIONAL_BUFFER_SIZE), BufferWithExtendableBuffer::DEFAULT_MAX_ADDITIONAL_BUFFER_SIZE),
mExpandableAddressTableBuffer( mExpandableAddressTableBuffer(
mAddressTableBuffer.get() ? mAddressTableBuffer.get()->getBuffer() : 0, mAddressTableBuffer.get() ? mAddressTableBuffer.get()->getBuffer() : nullptr,
mAddressTableBuffer.get() ? mAddressTableBuffer.get()->getBufferSize() : 0, mAddressTableBuffer.get() ? mAddressTableBuffer.get()->getBufferSize() : 0,
BufferWithExtendableBuffer::DEFAULT_MAX_ADDITIONAL_BUFFER_SIZE), BufferWithExtendableBuffer::DEFAULT_MAX_ADDITIONAL_BUFFER_SIZE),
mExpandableContentBuffer(mContentBuffer.get() ? mContentBuffer.get()->getBuffer() : 0, mExpandableContentBuffer(mContentBuffer.get() ?
mContentBuffer.get()->getBuffer() : nullptr,
mContentBuffer.get() ? mContentBuffer.get()->getBufferSize() : 0, mContentBuffer.get() ? mContentBuffer.get()->getBufferSize() : 0,
BufferWithExtendableBuffer::DEFAULT_MAX_ADDITIONAL_BUFFER_SIZE), BufferWithExtendableBuffer::DEFAULT_MAX_ADDITIONAL_BUFFER_SIZE),
mAddressLookupTable(&mExpandableLookupTableBuffer, &mExpandableAddressTableBuffer, mAddressLookupTable(&mExpandableLookupTableBuffer, &mExpandableAddressTableBuffer,
sparseTableBlockSize, sparseTableDataSize), sparseTableBlockSize, sparseTableDataSize),
mIsValid(mLookupTableBuffer.get() != 0 && mAddressTableBuffer.get() != 0 mIsValid(mLookupTableBuffer.get() && mAddressTableBuffer.get()
&& mContentBuffer.get() != 0) {} && mContentBuffer.get()) {}
SparseTableDictContent(const int sparseTableBlockSize, const int sparseTableDataSize) SparseTableDictContent(const int sparseTableBlockSize, const int sparseTableDataSize)
: mLookupTableBuffer(0), mAddressTableBuffer(0), mContentBuffer(0), : mLookupTableBuffer(0), mAddressTableBuffer(0), mContentBuffer(0),

View File

@ -31,7 +31,7 @@ namespace latinime {
if (!headerBuffer.get()) { if (!headerBuffer.get()) {
ASSERT(false); ASSERT(false);
AKLOGE("The header buffer must be valid to open ver4 dict buffers."); AKLOGE("The header buffer must be valid to open ver4 dict buffers.");
return Ver4DictBuffersPtr(0); return Ver4DictBuffersPtr(nullptr);
} }
// TODO: take only dictDirPath, and open both header and trie files in the constructor below // TODO: take only dictDirPath, and open both header and trie files in the constructor below
return Ver4DictBuffersPtr(new Ver4DictBuffers( return Ver4DictBuffersPtr(new Ver4DictBuffers(
@ -118,10 +118,10 @@ Ver4DictBuffers::Ver4DictBuffers(const char *const dictPath,
mDictBuffer(MmappedBuffer::openBuffer(dictPath, mDictBuffer(MmappedBuffer::openBuffer(dictPath,
Ver4DictConstants::TRIE_FILE_EXTENSION, isUpdatable)), Ver4DictConstants::TRIE_FILE_EXTENSION, isUpdatable)),
mHeaderPolicy(headerBuffer.get()->getBuffer(), FormatUtils::VERSION_4), mHeaderPolicy(headerBuffer.get()->getBuffer(), FormatUtils::VERSION_4),
mExpandableHeaderBuffer(headerBuffer.get() ? headerBuffer.get()->getBuffer() : 0, mExpandableHeaderBuffer(headerBuffer.get() ? headerBuffer.get()->getBuffer() : nullptr,
mHeaderPolicy.getSize(), mHeaderPolicy.getSize(),
BufferWithExtendableBuffer::DEFAULT_MAX_ADDITIONAL_BUFFER_SIZE), BufferWithExtendableBuffer::DEFAULT_MAX_ADDITIONAL_BUFFER_SIZE),
mExpandableTrieBuffer(mDictBuffer.get() ? mDictBuffer.get()->getBuffer() : 0, mExpandableTrieBuffer(mDictBuffer.get() ? mDictBuffer.get()->getBuffer() : nullptr,
mDictBuffer.get() ? mDictBuffer.get()->getBufferSize() : 0, mDictBuffer.get() ? mDictBuffer.get()->getBufferSize() : 0,
BufferWithExtendableBuffer::DEFAULT_MAX_ADDITIONAL_BUFFER_SIZE), BufferWithExtendableBuffer::DEFAULT_MAX_ADDITIONAL_BUFFER_SIZE),
mTerminalPositionLookupTable(dictPath, isUpdatable), mTerminalPositionLookupTable(dictPath, isUpdatable),

View File

@ -60,8 +60,8 @@ class MmappedBuffer {
// Empty file. We have to handle an empty file as a valid part of a dictionary. // Empty file. We have to handle an empty file as a valid part of a dictionary.
AK_FORCE_INLINE MmappedBuffer(const bool isUpdatable) AK_FORCE_INLINE MmappedBuffer(const bool isUpdatable)
: mBuffer(0), mBufferSize(0), mMmappedBuffer(0), mAlignedSize(0), mMmapFd(0), : mBuffer(nullptr), mBufferSize(0), mMmappedBuffer(nullptr), mAlignedSize(0),
mIsUpdatable(isUpdatable) {} mMmapFd(0), mIsUpdatable(isUpdatable) {}
DISALLOW_IMPLICIT_CONSTRUCTORS(MmappedBuffer); DISALLOW_IMPLICIT_CONSTRUCTORS(MmappedBuffer);