Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/context.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 | 36448afdadd4 |
children | 4ddffb793d18 |
comparison
equal
deleted
inserted
replaced
8526:f78eadbb5769 | 8527:f9a80054dd3c |
---|---|
442 | 442 |
443 acache = {} | 443 acache = {} |
444 | 444 |
445 # prime the ancestor cache for the working directory | 445 # prime the ancestor cache for the working directory |
446 for c in (self, fc2): | 446 for c in (self, fc2): |
447 if c._filerev == None: | 447 if c._filerev is None: |
448 pl = [(n.path(), n.filenode()) for n in c.parents()] | 448 pl = [(n.path(), n.filenode()) for n in c.parents()] |
449 acache[(c._path, None)] = pl | 449 acache[(c._path, None)] = pl |
450 | 450 |
451 flcache = {self._repopath:self._filelog, fc2._repopath:fc2._filelog} | 451 flcache = {self._repopath:self._filelog, fc2._repopath:fc2._filelog} |
452 def parents(vertex): | 452 def parents(vertex): |