From c28db659ed2eba95a75e4a41b07d01fc102bc64d Mon Sep 17 00:00:00 2001 From: mscdex Date: Sat, 27 Jul 2013 13:46:39 -0400 Subject: [PATCH] use more efficient emptiness checking Using empty() instead of size() can be faster. size() can take linear time but empty() is guaranteed to take constant time. --- src/database.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/database.cc b/src/database.cc index 7f0bd105..fa976c3a 100644 --- a/src/database.cc +++ b/src/database.cc @@ -104,7 +104,7 @@ void Database::ReleaseIterator (uint32_t id) { // if there is a pending CloseWorker it means that we're waiting for // iterators to end before we can close them iterators.erase(id); - if (iterators.size() == 0 && pendingCloseWorker != NULL) { + if (iterators.empty() && pendingCloseWorker != NULL) { AsyncQueueWorker((AsyncWorker*)pendingCloseWorker); pendingCloseWorker = NULL; } @@ -276,7 +276,7 @@ v8::Handle Database::Close (const v8::Arguments& args) { , v8::Persistent::New(LD_NODE_ISOLATE_PRE callback) ); - if (database->iterators.size() > 0) { + if (!database->iterators.empty()) { // yikes, we still have iterators open! naughty naughty. // we have to queue up a CloseWorker and manually close each of them. // the CloseWorker will be invoked once they are all cleaned up