Mercurial > hg
changeset 42113:f0def07fa82f
branchmap: implement __contains__()
We have good occurences of `if branch in branchmap()` in our code. If
__contains__() is not implemented then it will use __iter__() to find whether
the element exists or not which is not good.
I am bit confused that whether I should move existing callers to hasbranch() or
this patch is a good way.
Differential Revision: https://phab.mercurial-scm.org/D6206
author | Pulkit Goyal <pulkit@yandex-team.ru> |
---|---|
date | Sun, 31 Mar 2019 16:27:10 +0300 |
parents | 29c22496dd97 |
children | aa84bc48c2f7 |
files | mercurial/branchmap.py |
diffstat | 1 files changed, 3 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/branchmap.py Sun Mar 31 16:20:17 2019 +0300 +++ b/mercurial/branchmap.py Sun Mar 31 16:27:10 2019 +0300 @@ -182,6 +182,9 @@ def __getitem__(self, key): return self._entries[key] + def __contains__(self, key): + return key in self._entries + def iteritems(self): return self._entries.iteritems()