changeset 31437:084050d76e4f

context: explicitly tests for None Changeset 9e57033fec0c removed the mutable default value, but did not explicitly tested for None. Such implicit testing can introduce semantic and performance issue. We move to an explicit testing for None as recommended by PEP8: https://www.python.org/dev/peps/pep-0008/#programming-recommendations
author Pierre-Yves David <pierre-yves.david@ens-lyon.org>
date Wed, 15 Mar 2017 15:33:24 -0700
parents ac7aa96e4cd8
children 82350f7fa56c
files mercurial/context.py
diffstat 1 files changed, 7 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/context.py	Wed Mar 15 15:11:52 2017 -0700
+++ b/mercurial/context.py	Wed Mar 15 15:33:24 2017 -0700
@@ -300,8 +300,10 @@
 
     def match(self, pats=None, include=None, exclude=None, default='glob',
               listsubrepos=False, badfn=None):
+        if pats is None:
+            pats = []
         r = self._repo
-        return matchmod.match(r.root, r.getcwd(), pats or [],
+        return matchmod.match(r.root, r.getcwd(), pats,
                               include, exclude, default,
                               auditor=r.nofsauditor, ctx=self,
                               listsubrepos=listsubrepos, badfn=badfn)
@@ -1517,16 +1519,18 @@
 
     def match(self, pats=None, include=None, exclude=None, default='glob',
               listsubrepos=False, badfn=None):
+        if pats is None:
+            pats = []
         r = self._repo
 
         # Only a case insensitive filesystem needs magic to translate user input
         # to actual case in the filesystem.
         if not util.fscasesensitive(r.root):
-            return matchmod.icasefsmatcher(r.root, r.getcwd(), pats or [],
+            return matchmod.icasefsmatcher(r.root, r.getcwd(), pats,
                                            include, exclude, default, r.auditor,
                                            self, listsubrepos=listsubrepos,
                                            badfn=badfn)
-        return matchmod.match(r.root, r.getcwd(), pats or [],
+        return matchmod.match(r.root, r.getcwd(), pats,
                               include, exclude, default,
                               auditor=r.auditor, ctx=self,
                               listsubrepos=listsubrepos, badfn=badfn)