changeset 13200:6f011cf52f9a

avoid .split() in for loops and use tuples instead split can be more readable for longer lists like the list in dirstate.invalidate. As dirstate.invalidate is used in wlock() and therefoe used heavily, I think it's worth avoiding a split there too.
author David Soria Parra <dsp@php.net>
date Thu, 02 Dec 2010 03:43:06 +0100
parents a38df1250945
children f05250572467
files mercurial/dirstate.py mercurial/localrepo.py mercurial/util.py
diffstat 3 files changed, 5 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/dirstate.py	Mon Dec 06 16:56:06 2010 +0100
+++ b/mercurial/dirstate.py	Thu Dec 02 03:43:06 2010 +0100
@@ -230,7 +230,8 @@
             self._pl = p
 
     def invalidate(self):
-        for a in "_map _copymap _foldmap _branch _pl _dirs _ignore".split():
+        for a in ("_map", "_copymap", "_foldmap", "_branch", "_pl", "_dirs",
+                "_ignore"):
             if a in self.__dict__:
                 delattr(self, a)
         self._dirty = False
--- a/mercurial/localrepo.py	Mon Dec 06 16:56:06 2010 +0100
+++ b/mercurial/localrepo.py	Thu Dec 02 03:43:06 2010 +0100
@@ -733,7 +733,7 @@
         self._branchcachetip = None
 
     def invalidate(self):
-        for a in "changelog manifest".split():
+        for a in ("changelog", "manifest"):
             if a in self.__dict__:
                 delattr(self, a)
         self.invalidatecaches()
--- a/mercurial/util.py	Mon Dec 06 16:56:06 2010 +0100
+++ b/mercurial/util.py	Thu Dec 02 03:43:06 2010 +0100
@@ -1099,7 +1099,7 @@
         if not defaults:
             defaults = {}
         now = makedate()
-        for part in "d mb yY HI M S".split():
+        for part in ("d", "mb", "yY", "HI", "M", "S"):
             if part not in defaults:
                 if part[0] in "HMS":
                     defaults[part] = "00"
@@ -1146,7 +1146,7 @@
 
     def upper(date):
         d = dict(mb="12", HI="23", M="59", S="59")
-        for days in "31 30 29".split():
+        for days in ("31", "30", "29"):
             try:
                 d["d"] = days
                 return parsedate(date, extendeddateformats, d)[0]