Browse Source

[2856] Test lists and sets directly instead of using len()

Mukund Sivaraman 12 years ago
parent
commit
e61c29836e
2 changed files with 5 additions and 5 deletions
  1. 2 2
      src/lib/python/isc/memmgr/builder.py
  2. 3 3
      src/lib/python/isc/memmgr/datasrc_info.py

+ 2 - 2
src/lib/python/isc/memmgr/builder.py

@@ -144,7 +144,7 @@ class MemorySegmentBuilder:
         # Acquire the condition variable while running the loop.
         with self._cv:
             while not self._shutdown:
-                while len(self._command_queue) == 0:
+                while not self._command_queue:
                     self._cv.wait()
                 # Move the queue content to a local queue. Be careful of
                 # not making assignments to reference variables.
@@ -176,6 +176,6 @@ class MemorySegmentBuilder:
                 # Notify (any main thread) on the socket about a
                 # response. Otherwise, the main thread may wait in its
                 # loop without knowing there was a problem.
-                if len(self._response_queue) > 0:
+                if self._response_queue:
                     while self._sock.send(b'x') != 1:
                         continue

+ 3 - 3
src/lib/python/isc/memmgr/datasrc_info.py

@@ -109,9 +109,9 @@ class SegmentInfo:
     # Helper method used in complete_update(), sync_reader() and
     # remove_reader().
     def __sync_reader_helper(self, new_state):
-        if len(self.__old_readers) == 0:
+        if not self.__old_readers:
             self.__state = new_state
-            if len(self.__events) > 0:
+            if self.__events:
                 e = self.__events[0]
                 del self.__events[0]
                 return e
@@ -145,7 +145,7 @@ class SegmentInfo:
         event (without removing it from the pending events queue). This
         tells the caller (memmgr) that it should initiate the update
         process with the builder. In all other cases it returns None."""
-        if self.__state == self.READY and  len(self.__events) > 0:
+        if self.__state == self.READY and self.__events:
             self.__state = self.UPDATING
             return self.__events[0]