Patchwork [3,of,6,v2] dirstate: make dirstate._join a bit faster on posix

login
register
mail settings
Submitter Kostia Balytskyi
Date Sept. 19, 2017, 4:57 p.m.
Message ID <3294e39ad1c3adf26308.1505840267@devvm1416.lla2.facebook.com>
Download mbox | patch
Permalink /patch/24026/
State Deferred, archived
Headers show

Comments

Kostia Balytskyi - Sept. 19, 2017, 4:57 p.m.
# HG changeset patch
# User Kostia Balytskyi <ikostia@fb.com>
# Date 1505837513 25200
#      Tue Sep 19 09:11:53 2017 -0700
# Node ID 3294e39ad1c3adf26308eae859280437f1671220
# Parent  db7c6d368422041bb0d5ff5dafcd4cdaf3943fac
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.

Patch

diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
--- a/mercurial/dirstate.py
+++ b/mercurial/dirstate.py
@@ -268,8 +268,17 @@  class dirstate(object):
     def _checkcase(self):
         return not util.fscasesensitive(self._join('.hg'))
 
-    def _join(self, f):
-        return util.absjoin(self._rootdir, f)
+    if pycompat.osname == 'nt':
+        def _join(self, f):
+            return util.absjoin(self._rootdir, f)
+
+    else:
+        def _join(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: