Benoit Boissinot avatar Benoit Boissinot committed 3492f44

dirstate: no need to iterate twice, a dict can be updated in place

Comments (0)

Files changed (1)

mercurial/dirstate.py

         # use the modification time of the newly created temporary file as the
         # filesystem's notion of 'now'
         now = int(util.fstat(st).st_mtime)
-        for f in self._map.keys():
-            e = self._map[f]
+
+        cs = cStringIO.StringIO()
+        copymap = self._copymap
+        pack = struct.pack
+        write = cs.write
+        write("".join(self._pl))
+        for f, e in self._map.iteritems():
             if e[0] == 'n' and e[3] == now:
                 # The file was last modified "simultaneously" with the current
                 # write to dirstate (i.e. within the same second for file-
                 # dirstate, forcing future 'status' calls to compare the
                 # contents of the file. This prevents mistakenly treating such
                 # files as clean.
-                self._map[f] = (e[0], 0, -1, -1)   # mark entry as 'unset'
+                e = (e[0], 0, -1, -1)   # mark entry as 'unset'
+                self._map[f] = e
 
-        cs = cStringIO.StringIO()
-        copymap = self._copymap
-        pack = struct.pack
-        write = cs.write
-        write("".join(self._pl))
-        for f, e in self._map.iteritems():
             if f in copymap:
                 f = "%s\0%s" % (f, copymap[f])
             e = pack(_format, e[0], e[1], e[2], e[3], len(f))
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.