# HG changeset patch
# User Kostia Balytskyi <ikos...@fb.com>
# Date 1502522493 25200
#      Sat Aug 12 00:21:33 2017 -0700
# Node ID bac7b1ae4a0c998c57cea5eac51af66853779918
# Parent  a1c8f310a66ada40697c824f4621bb54c757e9fa
dirstate: make dirstate._join a bit faster on posix

This is a micro-optimization, suggested by @quark for one of the previous
patches. It is safe to land the series without this micro-optimization.

diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
--- a/mercurial/dirstate.py
+++ b/mercurial/dirstate.py
@@ -99,6 +99,9 @@ class dirstate(object):
         # for consistent view between _pl() and _read() invocations
         self._pendingmode = None
 
+        if pycompat.osname != 'nt':
+            self._join = self._join_posix
+
     @contextlib.contextmanager
     def parentchange(self):
         '''Context manager for handling dirstate parents.
@@ -271,6 +274,13 @@ class dirstate(object):
     def _join(self, f):
         return util.absjoin(self._rootdir, f)
 
+    def _join_posix(self, f):
+        # The cross-platform _join() has windows-specific logic that
+        # is much more branchy. Since this is called O(files in working copy)
+        # times regularly, we microoptimize here.
+        # This is safe because f is always a relative path.
+        return self._rootdir + f
+
     def flagfunc(self, buildfallback):
         if self._checklink and self._checkexec:
             def f(x):
_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Reply via email to