Skip to content

Instantly share code, notes, and snippets.

@hgaiser
Last active September 29, 2015 12:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hgaiser/c79ac1f05b7be198d9d3 to your computer and use it in GitHub Desktop.
Save hgaiser/c79ac1f05b7be198d9d3 to your computer and use it in GitHub Desktop.
Removes tautological null checks in mongodb.
diff --git a/src/mongo/client/dbclientcursor.h b/src/mongo/client/dbclientcursor.h
index 785734d..11b6349 100644
--- a/src/mongo/client/dbclientcursor.h
+++ b/src/mongo/client/dbclientcursor.h
@@ -116,7 +116,7 @@ namespace mongo {
'dead' may be preset yet some data still queued and locally
available from the dbclientcursor.
*/
- bool isDead() const { return !this || cursorId == 0; }
+ bool isDead() const { return cursorId == 0; }
bool tailable() const { return (opts & QueryOption_CursorTailable) != 0; }
diff --git a/src/mongo/client/dbclientcursor.cpp b/src/mongo/client/dbclientcursor.cpp
index f6dc575..468ed78 100644
--- a/src/mongo/client/dbclientcursor.cpp
+++ b/src/mongo/client/dbclientcursor.cpp
@@ -308,9 +308,6 @@ namespace mongo {
}
DBClientCursor::~DBClientCursor() {
- if (!this)
- return;
-
DESTRUCTOR_GUARD (
if ( cursorId && _ownCursor && ! inShutdown() ) {
diff --git a/src/mongo/util/concurrency/mutexdebugger.h b/src/mongo/util/concurrency/mutexdebugger.h.bak
index f0674e6..ff652ff 100644
--- a/src/mongo/util/concurrency/mutexdebugger.h
+++ b/src/mongo/util/concurrency/mutexdebugger.h.bak
@@ -87,7 +87,7 @@ namespace mongo {
}
void entering(mid m) {
- if( this == 0 || m == 0 ) return;
+ if( m == 0 ) return;
verify( magic == 0x12345678 );
Preceeding *_preceeding = us.get();
@@ -147,7 +147,7 @@ namespace mongo {
}
}
void leaving(mid m) {
- if( this == 0 || m == 0 ) return; // still in startup pre-main()
+ if( m == 0 ) return; // still in startup pre-main()
Preceeding& preceeding = *us.get();
preceeding[m]--;
if( preceeding[m] < 0 ) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment