Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/localrepo.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 | 865e08a7d6b0 |
children | 810387f59696 |
comparison
equal
deleted
inserted
replaced
8526:f78eadbb5769 | 8527:f9a80054dd3c |
---|---|
105 @propertycache | 105 @propertycache |
106 def dirstate(self): | 106 def dirstate(self): |
107 return dirstate.dirstate(self.opener, self.ui, self.root) | 107 return dirstate.dirstate(self.opener, self.ui, self.root) |
108 | 108 |
109 def __getitem__(self, changeid): | 109 def __getitem__(self, changeid): |
110 if changeid == None: | 110 if changeid is None: |
111 return context.workingctx(self) | 111 return context.workingctx(self) |
112 return context.changectx(self, changeid) | 112 return context.changectx(self, changeid) |
113 | 113 |
114 def __nonzero__(self): | 114 def __nonzero__(self): |
115 return True | 115 return True |
1207 m = self.changelog.nodemap | 1207 m = self.changelog.nodemap |
1208 search = [] | 1208 search = [] |
1209 fetch = set() | 1209 fetch = set() |
1210 seen = set() | 1210 seen = set() |
1211 seenbranch = set() | 1211 seenbranch = set() |
1212 if base == None: | 1212 if base is None: |
1213 base = {} | 1213 base = {} |
1214 | 1214 |
1215 if not heads: | 1215 if not heads: |
1216 heads = remote.heads() | 1216 heads = remote.heads() |
1217 | 1217 |
1339 exist on the remote side. | 1339 exist on the remote side. |
1340 If a list of heads is specified, return only nodes which are heads | 1340 If a list of heads is specified, return only nodes which are heads |
1341 or ancestors of these heads, and return a second element which | 1341 or ancestors of these heads, and return a second element which |
1342 contains all remote heads which get new children. | 1342 contains all remote heads which get new children. |
1343 """ | 1343 """ |
1344 if base == None: | 1344 if base is None: |
1345 base = {} | 1345 base = {} |
1346 self.findincoming(remote, base, heads, force=force) | 1346 self.findincoming(remote, base, heads, force=force) |
1347 | 1347 |
1348 self.ui.debug(_("common changesets up to ") | 1348 self.ui.debug(_("common changesets up to ") |
1349 + " ".join(map(short, base.keys())) + "\n") | 1349 + " ".join(map(short, base.keys())) + "\n") |