Patchwork [08,of,13] largefiles: use constant for '.hglf/'

login
register
mail settings
Submitter Mads Kiilerich
Date Dec. 21, 2012, 7:06 p.m.
Message ID <e2c63ee6bf0e9d95494a.1356116817@mk-desktop>
Download mbox | patch
Permalink /patch/257/
State Accepted
Commit 90ad387d924521272eb835b81531268094c7ca4e
Headers show

Comments

Mads Kiilerich - Dec. 21, 2012, 7:06 p.m.
# HG changeset patch
# User Mads Kiilerich <madski at unity3d.com>
# Date 1355422746 -3600
# Node ID e2c63ee6bf0e9d95494a4c4cf948223d4a8e1b1d
# Parent  154e52eaae10447e618f88210b7c7f47dcd3fa5e
largefiles: use constant for '.hglf/'

Problem: '.hglf' + '/' was computed in some tight loops.

Patch

diff --git a/hgext/largefiles/lfutil.py b/hgext/largefiles/lfutil.py
--- a/hgext/largefiles/lfutil.py
+++ b/hgext/largefiles/lfutil.py
@@ -18,6 +18,7 @@ 
 from mercurial.i18n import _
 
 shortname = '.hglf'
+shortnameslash = shortname + '/'
 longname = 'largefiles'
 
 
@@ -291,12 +292,12 @@ 
     # 2) Join with '/' because that's what dirstate always uses, even on
     #    Windows. Change existing separator to '/' first in case we are
     #    passed filenames from an external source (like the command line).
-    return shortname + '/' + util.pconvert(filename)
+    return shortnameslash + util.pconvert(filename)
 
 def isstandin(filename):
     '''Return true if filename is a big file standin. filename must be
     in Mercurial's internal form (slash-separated).'''
-    return filename.startswith(shortname + '/')
+    return filename.startswith(shortnameslash)
 
 def splitstandin(filename):
     # Split on / because that's what dirstate always uses, even on Windows.
@@ -425,7 +426,7 @@ 
 
 def islfilesrepo(repo):
     if ('largefiles' in repo.requirements and
-            util.any(shortname + '/' in f[0] for f in repo.store.datafiles())):
+            util.any(shortnameslash in f[0] for f in repo.store.datafiles())):
         return True
 
     return util.any(openlfdirstate(repo.ui, repo, False))