[Pkg-javascript-commits] [node-leveldown] 372/492: use more efficient emptiness checking

Andrew Kelley andrewrk-guest at moszumanska.debian.org
Sun Jul 6 17:14:18 UTC 2014


This is an automated email from the git hooks/post-receive script.

andrewrk-guest pushed a commit to annotated tag rocksdb-0.10.1
in repository node-leveldown.

commit c28db659ed2eba95a75e4a41b07d01fc102bc64d
Author: mscdex <mscdex at mscdex.net>
Date:   Sat Jul 27 13:46:39 2013 -0400

    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 7f0bd10..fa976c3 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<v8::Value> Database::Close (const v8::Arguments& args) {
     , v8::Persistent<v8::Function>::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

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-leveldown.git



More information about the Pkg-javascript-commits mailing list