diff mercurial/revlog.py @ 8527:f9a80054dd3c

use 'x is None' instead of 'x == None' The built-in None object is a singleton and it is therefore safe to compare memory addresses with is. It is also faster, how much depends on the object being compared. For a simple type like str I get: | s = "foo" | s = None ----------+-----------+---------- s == None | 0.25 usec | 0.21 usec s is None | 0.17 usec | 0.17 usec
author Martin Geisler <mg@lazybytes.net>
date Wed, 20 May 2009 00:52:46 +0200
parents 7af92e70bb25
children 5726bb290bfe
line wrap: on
line diff
--- a/mercurial/revlog.py	Wed May 20 00:43:23 2009 +0200
+++ b/mercurial/revlog.py	Wed May 20 00:52:46 2009 +0200
@@ -175,7 +175,7 @@
         if lend > len(self.index) - i:
             lend = len(self.index) - i
         for x in xrange(lend):
-            if self.index[i + x] == None:
+            if self.index[i + x] is None:
                 b = data[off : off + self.s]
                 self.index[i + x] = b
                 n = b[ngshaoffset:ngshaoffset + 20]
@@ -231,7 +231,7 @@
         if self.all:
             return
         all = False
-        if i == None:
+        if i is None:
             blockstart = 0
             blocksize = (65536 / self.s) * self.s
             end = self.datasize
@@ -279,7 +279,7 @@
         self.p = parser
     def load(self, key):
         n = self.p.findnode(key)
-        if n == None:
+        if n is None:
             raise KeyError(key)
     def __contains__(self, key):
         if key in self.p.map:
@@ -1019,7 +1019,7 @@
             return
 
         trinfo = tr.find(self.indexfile)
-        if trinfo == None:
+        if trinfo is None:
             raise RevlogError(_("%s not found in the transaction")
                               % self.indexfile)