changeset 31392:6168d4b93634

match: don't use mutable default argument value There shouldn't be a big perf hit creating a new object because this function is complicated and does things that dwarf the cost of creating a new PyObject.
author Gregory Szorc <gregory.szorc@gmail.com>
date Sun, 12 Mar 2017 21:53:03 -0700
parents d2878bec55bd
children 8b6927eb7efd
files mercurial/match.py
diffstat 1 files changed, 3 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/match.py	Sun Mar 12 21:52:17 2017 -0700
+++ b/mercurial/match.py	Sun Mar 12 21:53:03 2017 -0700
@@ -85,7 +85,7 @@
     return True
 
 class match(object):
-    def __init__(self, root, cwd, patterns, include=[], exclude=[],
+    def __init__(self, root, cwd, patterns, include=None, exclude=None,
                  default='glob', exact=False, auditor=None, ctx=None,
                  listsubrepos=False, warn=None, badfn=None):
         """build an object to match a set of file patterns
@@ -117,6 +117,8 @@
                               the same directory
         '<something>' - a pattern of the specified default type
         """
+        include = include or []
+        exclude = exclude or []
 
         self._root = root
         self._cwd = cwd