"NULL !=" = NULL
R=reed@google.com
Author: bsalomon@google.com
Review URL: https://codereview.chromium.org/544233002
diff --git a/include/core/SkBitmap.h b/include/core/SkBitmap.h
index 4e512c0..b36a1fd 100644
--- a/include/core/SkBitmap.h
+++ b/include/core/SkBitmap.h
@@ -444,7 +444,7 @@
*/
bool readyToDraw() const {
return this->getPixels() != NULL &&
- (this->colorType() != kIndex_8_SkColorType || NULL != fColorTable);
+ (this->colorType() != kIndex_8_SkColorType || fColorTable);
}
/** Returns the pixelRef's texture, or NULL
diff --git a/include/core/SkCanvas.h b/include/core/SkCanvas.h
index 6b2266a..f514d18 100644
--- a/include/core/SkCanvas.h
+++ b/include/core/SkCanvas.h
@@ -1442,13 +1442,13 @@
public:
SkAutoCommentBlock(SkCanvas* canvas, const char* description) {
fCanvas = canvas;
- if (NULL != fCanvas) {
+ if (fCanvas) {
fCanvas->beginCommentGroup(description);
}
}
~SkAutoCommentBlock() {
- if (NULL != fCanvas) {
+ if (fCanvas) {
fCanvas->endCommentGroup();
}
}
diff --git a/include/core/SkMatrix.h b/include/core/SkMatrix.h
index d2fb737..9f44bed 100644
--- a/include/core/SkMatrix.h
+++ b/include/core/SkMatrix.h
@@ -349,7 +349,7 @@
bool SK_WARN_UNUSED_RESULT invert(SkMatrix* inverse) const {
// Allow the trivial case to be inlined.
if (this->isIdentity()) {
- if (NULL != inverse) {
+ if (inverse) {
inverse->reset();
}
return true;
diff --git a/include/core/SkMetaData.h b/include/core/SkMetaData.h
index 5db437c..c8ca7f1 100644
--- a/include/core/SkMetaData.h
+++ b/include/core/SkMetaData.h
@@ -81,7 +81,7 @@
bool hasData(const char name[], const void* data, size_t byteCount) const {
size_t len;
const void* ptr = this->findData(name, &len);
- return NULL != ptr && len == byteCount && !memcmp(ptr, data, len);
+ return ptr && len == byteCount && !memcmp(ptr, data, len);
}
void setS32(const char name[], int32_t value);
diff --git a/include/core/SkPathRef.h b/include/core/SkPathRef.h
index ba68fcb..0b661b4 100644
--- a/include/core/SkPathRef.h
+++ b/include/core/SkPathRef.h
@@ -144,7 +144,7 @@
* fact ovals can report false.
*/
bool isOval(SkRect* rect) const {
- if (fIsOval && NULL != rect) {
+ if (fIsOval && rect) {
*rect = getBounds();
}
diff --git a/include/core/SkRefCnt.h b/include/core/SkRefCnt.h
index ce38c67..f092e77 100644
--- a/include/core/SkRefCnt.h
+++ b/include/core/SkRefCnt.h
@@ -168,7 +168,7 @@
}
template<typename T> static inline void SkSafeSetNull(T*& obj) {
- if (NULL != obj) {
+ if (obj) {
obj->unref();
obj = NULL;
}
diff --git a/include/core/SkTArray.h b/include/core/SkTArray.h
index 6c76c78..06a85bc 100644
--- a/include/core/SkTArray.h
+++ b/include/core/SkTArray.h
@@ -384,7 +384,7 @@
gMIN_ALLOC_COUNT;
fPreAllocMemArray = preAllocStorage;
if (fReserveCount >= fCount &&
- NULL != preAllocStorage) {
+ preAllocStorage) {
fAllocCount = fReserveCount;
fMemArray = preAllocStorage;
} else {
@@ -427,7 +427,7 @@
fAllocCount = newAllocCount;
char* newMemArray;
- if (fAllocCount == fReserveCount && NULL != fPreAllocMemArray) {
+ if (fAllocCount == fReserveCount && fPreAllocMemArray) {
newMemArray = (char*) fPreAllocMemArray;
} else {
newMemArray = (char*) sk_malloc_throw(fAllocCount*sizeof(T));
diff --git a/include/core/SkTInternalLList.h b/include/core/SkTInternalLList.h
index 1c82a71..1aa1a12 100644
--- a/include/core/SkTInternalLList.h
+++ b/include/core/SkTInternalLList.h
@@ -46,18 +46,18 @@
}
void remove(T* entry) {
- SkASSERT(NULL != fHead && NULL != fTail);
+ SkASSERT(fHead && fTail);
SkASSERT(this->isInList(entry));
T* prev = entry->fPrev;
T* next = entry->fNext;
- if (NULL != prev) {
+ if (prev) {
prev->fNext = next;
} else {
fHead = next;
}
- if (NULL != next) {
+ if (next) {
next->fPrev = prev;
} else {
fTail = prev;
@@ -77,7 +77,7 @@
entry->fPrev = NULL;
entry->fNext = fHead;
- if (NULL != fHead) {
+ if (fHead) {
fHead->fPrev = entry;
}
fHead = entry;
@@ -96,7 +96,7 @@
entry->fPrev = fTail;
entry->fNext = NULL;
- if (NULL != fTail) {
+ if (fTail) {
fTail->fNext = entry;
}
fTail = entry;
@@ -115,7 +115,7 @@
* at the tail.
*/
void addBefore(T* newEntry, T* existingEntry) {
- SkASSERT(NULL != newEntry);
+ SkASSERT(newEntry);
if (NULL == existingEntry) {
this->addToTail(newEntry);
@@ -144,7 +144,7 @@
* at the head.
*/
void addAfter(T* newEntry, T* existingEntry) {
- SkASSERT(NULL != newEntry);
+ SkASSERT(newEntry);
if (NULL == existingEntry) {
this->addToHead(newEntry);
@@ -227,7 +227,7 @@
void validate() const {
SkASSERT(!fHead == !fTail);
Iter iter;
- for (T* item = iter.init(*this, Iter::kHead_IterStart); NULL != item; item = iter.next()) {
+ for (T* item = iter.init(*this, Iter::kHead_IterStart); item; item = iter.next()) {
SkASSERT(this->isInList(item));
if (NULL == item->fPrev) {
SkASSERT(fHead == item);
@@ -255,7 +255,7 @@
*/
int countEntries() const {
int count = 0;
- for (T* entry = fHead; NULL != entry; entry = entry->fNext) {
+ for (T* entry = fHead; entry; entry = entry->fNext) {
++count;
}
return count;
diff --git a/include/core/SkTLazy.h b/include/core/SkTLazy.h
index a291e22..a1dc001 100644
--- a/include/core/SkTLazy.h
+++ b/include/core/SkTLazy.h
@@ -88,7 +88,7 @@
* Returns true if a valid object has been initialized in the SkTLazy,
* false otherwise.
*/
- bool isValid() const { return NULL != fPtr; }
+ bool isValid() const { return SkToBool(fPtr); }
/**
* Returns the object. This version should only be called when the caller
@@ -166,7 +166,7 @@
* Returns a writable T*. The first time this is called the initial object is cloned.
*/
T* writable() {
- SkASSERT(NULL != fObj);
+ SkASSERT(fObj);
if (!fLazy.isValid()) {
fLazy.set(*fObj);
fObj = fLazy.get();
diff --git a/include/core/SkTemplates.h b/include/core/SkTemplates.h
index f561f46..5ef28ea 100644
--- a/include/core/SkTemplates.h
+++ b/include/core/SkTemplates.h
@@ -170,7 +170,7 @@
public:
SkAutoTDestroy(T* obj = NULL) : fObj(obj) {}
~SkAutoTDestroy() {
- if (NULL != fObj) {
+ if (fObj) {
fObj->~T();
}
}
diff --git a/include/core/SkTypes.h b/include/core/SkTypes.h
index bdd2e93..0e9e230 100644
--- a/include/core/SkTypes.h
+++ b/include/core/SkTypes.h
@@ -539,7 +539,7 @@
*/
void* reset(size_t size, OnShrink shrink = kAlloc_OnShrink, bool* didChangeAlloc = NULL) {
if (size == fSize || (kReuse_OnShrink == shrink && size < fSize)) {
- if (NULL != didChangeAlloc) {
+ if (didChangeAlloc) {
*didChangeAlloc = false;
}
return fPtr;
@@ -548,7 +548,7 @@
sk_free(fPtr);
fPtr = size ? sk_malloc_throw(size) : NULL;
fSize = size;
- if (NULL != didChangeAlloc) {
+ if (didChangeAlloc) {
*didChangeAlloc = true;
}
@@ -643,7 +643,7 @@
bool* didChangeAlloc = NULL) {
size = (size < kSize) ? kSize : size;
bool alloc = size != fSize && (SkAutoMalloc::kAlloc_OnShrink == shrink || size > fSize);
- if (NULL != didChangeAlloc) {
+ if (didChangeAlloc) {
*didChangeAlloc = alloc;
}
if (alloc) {
diff --git a/include/gpu/GrClipData.h b/include/gpu/GrClipData.h
index 1dc4b0d..12a23b3 100644
--- a/include/gpu/GrClipData.h
+++ b/include/gpu/GrClipData.h
@@ -35,7 +35,7 @@
return false;
}
- if (NULL != fClipStack && NULL != other.fClipStack) {
+ if (fClipStack && other.fClipStack) {
return *fClipStack == *other.fClipStack;
}
diff --git a/include/gpu/GrContext.h b/include/gpu/GrContext.h
index 4f9b642..4172543 100644
--- a/include/gpu/GrContext.h
+++ b/include/gpu/GrContext.h
@@ -745,7 +745,7 @@
fContext = context;
}
~AutoRenderTarget() {
- if (NULL != fContext) {
+ if (fContext) {
fContext->setRenderTarget(fPrevTarget);
}
SkSafeUnref(fPrevTarget);
@@ -779,7 +779,7 @@
* Initializes by pre-concat'ing the context's current matrix with the preConcat param.
*/
void setPreConcat(GrContext* context, const SkMatrix& preConcat, GrPaint* paint = NULL) {
- SkASSERT(NULL != context);
+ SkASSERT(context);
this->restore();
@@ -793,11 +793,11 @@
* update a paint but the matrix cannot be inverted.
*/
bool setIdentity(GrContext* context, GrPaint* paint = NULL) {
- SkASSERT(NULL != context);
+ SkASSERT(context);
this->restore();
- if (NULL != paint) {
+ if (paint) {
if (!paint->localCoordChangeInverse(context->getMatrix())) {
return false;
}
@@ -813,7 +813,7 @@
* required to update a paint but the matrix cannot be inverted.
*/
bool set(GrContext* context, const SkMatrix& newMatrix, GrPaint* paint = NULL) {
- if (NULL != paint) {
+ if (paint) {
if (!this->setIdentity(context, paint)) {
return false;
}
@@ -835,7 +835,7 @@
* performs an incremental update of the paint.
*/
void preConcat(const SkMatrix& preConcat, GrPaint* paint = NULL) {
- if (NULL != paint) {
+ if (paint) {
paint->localCoordChange(preConcat);
}
fContext->concatMatrix(preConcat);
@@ -845,13 +845,13 @@
* Returns false if never initialized or the inverse matrix was required to update a paint
* but the matrix could not be inverted.
*/
- bool succeeded() const { return NULL != fContext; }
+ bool succeeded() const { return SkToBool(fContext); }
/**
* If this has been initialized then the context's original matrix is restored.
*/
void restore() {
- if (NULL != fContext) {
+ if (fContext) {
fContext->setMatrix(fMatrix);
fContext = NULL;
}
@@ -890,7 +890,7 @@
}
~AutoClip() {
- if (NULL != fContext) {
+ if (fContext) {
fContext->setClip(fOldClip);
}
}
@@ -1091,7 +1091,7 @@
}
void reset() {
- if (NULL != fContext && NULL != fTexture) {
+ if (fContext && fTexture) {
fContext->unlockScratchTexture(fTexture);
fTexture->unref();
fTexture = NULL;
@@ -1124,7 +1124,7 @@
SkASSERT(!texture->unique());
texture->impl()->setFlag((GrTextureFlags) GrTextureImpl::kReturnToCache_FlagBit);
texture->unref();
- SkASSERT(NULL != texture->getCacheEntry());
+ SkASSERT(texture->getCacheEntry());
return texture;
}
@@ -1135,7 +1135,7 @@
this->reset();
fContext = context;
- if (NULL != fContext) {
+ if (fContext) {
fTexture = fContext->lockAndRefScratchTexture(desc, match);
if (NULL == fTexture) {
fContext = NULL;
diff --git a/include/gpu/GrContextFactory.h b/include/gpu/GrContextFactory.h
index bc06594..d78120c 100644
--- a/include/gpu/GrContextFactory.h
+++ b/include/gpu/GrContextFactory.h
@@ -95,11 +95,11 @@
void destroyContexts() {
for (int i = 0; i < fContexts.count(); ++i) {
- if (NULL != fContexts[i].fGLContext) { // could be abandoned.
+ if (fContexts[i].fGLContext) { // could be abandoned.
fContexts[i].fGLContext->makeCurrent();
}
fContexts[i].fGrContext->unref();
- if (NULL != fContexts[i].fGLContext) {
+ if (fContexts[i].fGLContext) {
fContexts[i].fGLContext->unref();
}
}
@@ -108,7 +108,7 @@
void abandonContexts() {
for (int i = 0; i < fContexts.count(); ++i) {
- if (NULL != fContexts[i].fGLContext) {
+ if (fContexts[i].fGLContext) {
fContexts[i].fGLContext->testAbandon();
SkSafeSetNull(fContexts[i].fGLContext);
}
diff --git a/include/gpu/GrCoordTransform.h b/include/gpu/GrCoordTransform.h
index 0bd7da0..734c26f 100644
--- a/include/gpu/GrCoordTransform.h
+++ b/include/gpu/GrCoordTransform.h
@@ -63,7 +63,7 @@
void reset(GrCoordSet sourceCoords, const GrTexture* texture) {
SkASSERT(!fInEffect);
- SkASSERT(NULL != texture);
+ SkASSERT(texture);
this->reset(sourceCoords, MakeDivByTextureWHMatrix(texture), texture);
}
@@ -71,7 +71,7 @@
SkASSERT(!fInEffect);
fSourceCoords = sourceCoords;
fMatrix = m;
- fReverseY = NULL != texture && kBottomLeft_GrSurfaceOrigin == texture->origin();
+ fReverseY = texture && kBottomLeft_GrSurfaceOrigin == texture->origin();
}
GrCoordTransform& operator= (const GrCoordTransform& other) {
@@ -104,7 +104,7 @@
/** Useful for effects that want to insert a texture matrix that is implied by the texture
dimensions */
static inline SkMatrix MakeDivByTextureWHMatrix(const GrTexture* texture) {
- SkASSERT(NULL != texture);
+ SkASSERT(texture);
SkMatrix mat;
mat.setIDiv(texture->width(), texture->height());
return mat;
diff --git a/include/gpu/GrDrawEffect.h b/include/gpu/GrDrawEffect.h
index 6aff82e..2bf17d8 100644
--- a/include/gpu/GrDrawEffect.h
+++ b/include/gpu/GrDrawEffect.h
@@ -21,8 +21,8 @@
GrDrawEffect(const GrEffectStage& stage, bool explicitLocalCoords)
: fEffectStage(&stage)
, fExplicitLocalCoords(explicitLocalCoords) {
- SkASSERT(NULL != fEffectStage);
- SkASSERT(NULL != fEffectStage->getEffect());
+ SkASSERT(fEffectStage);
+ SkASSERT(fEffectStage->getEffect());
}
const GrEffect* effect() const { return fEffectStage->getEffect(); }
diff --git a/include/gpu/GrEffectStage.h b/include/gpu/GrEffectStage.h
index 65c7beb..f4cee51 100644
--- a/include/gpu/GrEffectStage.h
+++ b/include/gpu/GrEffectStage.h
@@ -43,8 +43,8 @@
static bool AreCompatible(const GrEffectStage& a, const GrEffectStage& b,
bool usingExplicitLocalCoords) {
- SkASSERT(NULL != a.fEffect.get());
- SkASSERT(NULL != b.fEffect.get());
+ SkASSERT(a.fEffect.get());
+ SkASSERT(b.fEffect.get());
if (!a.getEffect()->isEqual(*b.getEffect())) {
return false;
diff --git a/include/gpu/GrGpuResource.h b/include/gpu/GrGpuResource.h
index c81e022..626f027 100644
--- a/include/gpu/GrGpuResource.h
+++ b/include/gpu/GrGpuResource.h
@@ -186,7 +186,7 @@
GrGpuResource(GrGpu*, bool isWrapped);
virtual ~GrGpuResource();
- bool isInCache() const { return NULL != fCacheEntry; }
+ bool isInCache() const { return SkToBool(fCacheEntry); }
GrGpu* getGpu() const { return fGpu; }
diff --git a/include/gpu/GrPaint.h b/include/gpu/GrPaint.h
index 20dec35..900ab4c 100644
--- a/include/gpu/GrPaint.h
+++ b/include/gpu/GrPaint.h
@@ -88,7 +88,7 @@
* Appends an additional color effect to the color computation.
*/
const GrEffect* addColorEffect(const GrEffect* effect, int attr0 = -1, int attr1 = -1) {
- SkASSERT(NULL != effect);
+ SkASSERT(effect);
if (!effect->willUseInputColor()) {
fColorStages.reset();
}
@@ -100,7 +100,7 @@
* Appends an additional coverage effect to the coverage computation.
*/
const GrEffect* addCoverageEffect(const GrEffect* effect, int attr0 = -1, int attr1 = -1) {
- SkASSERT(NULL != effect);
+ SkASSERT(effect);
if (!effect->willUseInputColor()) {
fCoverageStages.reset();
}
diff --git a/include/gpu/GrProgramElementRef.h b/include/gpu/GrProgramElementRef.h
index ea11f44..1e3b4f8 100644
--- a/include/gpu/GrProgramElementRef.h
+++ b/include/gpu/GrProgramElementRef.h
@@ -55,7 +55,7 @@
}
~GrProgramElementRef() {
- if (NULL != fObj) {
+ if (fObj) {
if (fOwnPendingExec) {
fObj->completedExecution();
} else {
diff --git a/include/gpu/GrRenderTarget.h b/include/gpu/GrRenderTarget.h
index 6a3f26f..4c5ec18 100644
--- a/include/gpu/GrRenderTarget.h
+++ b/include/gpu/GrRenderTarget.h
@@ -162,7 +162,7 @@
friend class GrTexture;
// called by ~GrTexture to remove the non-ref'ed back ptr.
void owningTextureDestroyed() {
- SkASSERT(NULL != fTexture);
+ SkASSERT(fTexture);
fTexture = NULL;
}
diff --git a/include/gpu/GrSurface.h b/include/gpu/GrSurface.h
index 6087ef4..8315c63 100644
--- a/include/gpu/GrSurface.h
+++ b/include/gpu/GrSurface.h
@@ -80,11 +80,11 @@
*/
bool isSameAs(const GrSurface* other) const {
const GrRenderTarget* thisRT = this->asRenderTarget();
- if (NULL != thisRT) {
+ if (thisRT) {
return thisRT == other->asRenderTarget();
} else {
const GrTexture* thisTex = this->asTexture();
- SkASSERT(NULL != thisTex); // We must be one or the other
+ SkASSERT(thisTex); // We must be one or the other
return thisTex == other->asTexture();
}
}
diff --git a/include/gpu/gl/SkGLContextHelper.h b/include/gpu/gl/SkGLContextHelper.h
index 8eab62e..c4d9bdf 100644
--- a/include/gpu/gl/SkGLContextHelper.h
+++ b/include/gpu/gl/SkGLContextHelper.h
@@ -46,7 +46,7 @@
virtual void swapBuffers() const = 0;
bool hasExtension(const char* extensionName) const {
- SkASSERT(NULL != fGL);
+ SkASSERT(fGL);
return fGL->hasExtension(extensionName);
}
diff --git a/include/pipe/SkGPipe.h b/include/pipe/SkGPipe.h
index 879ab04..98e081d 100644
--- a/include/pipe/SkGPipe.h
+++ b/include/pipe/SkGPipe.h
@@ -99,7 +99,7 @@
SkGPipeWriter();
~SkGPipeWriter();
- bool isRecording() const { return NULL != fCanvas; }
+ bool isRecording() const { return SkToBool(fCanvas); }
enum Flags {
/**
diff --git a/include/utils/win/SkTScopedComPtr.h b/include/utils/win/SkTScopedComPtr.h
index 8f18a42..38d1048 100644
--- a/include/utils/win/SkTScopedComPtr.h
+++ b/include/utils/win/SkTScopedComPtr.h
@@ -54,7 +54,7 @@
T **operator&() { SkASSERT(fPtr == NULL); return &fPtr; }
T *get() const { return fPtr; }
void reset() {
- if (NULL != this->fPtr) {
+ if (this->fPtr) {
this->fPtr->Release();
this->fPtr = NULL;
}
diff --git a/include/views/SkView.h b/include/views/SkView.h
index d03c741..c083cf1 100644
--- a/include/views/SkView.h
+++ b/include/views/SkView.h
@@ -210,7 +210,7 @@
* Return true on success; false on failure
*/
bool globalToLocal(SkPoint* pt) const {
- if (NULL != pt) {
+ if (pt) {
return this->globalToLocal(pt->fX, pt->fY, pt);
}
return true; // nothing to do so return true