revsetlang: avoid string concatenation in formatspec()
authorYuya Nishihara <yuya@tcha.org>
Sat, 01 Apr 2017 16:50:11 +0900
changeset 35557 2df8d12f23bc
parent 35556 b58964b9b541
child 35558 dfc628611144
revsetlang: avoid string concatenation in formatspec()
mercurial/revsetlang.py
--- a/mercurial/revsetlang.py	Thu Jan 04 12:30:55 2018 +0900
+++ b/mercurial/revsetlang.py	Sat Apr 01 16:50:11 2017 +0900
@@ -620,7 +620,7 @@
         return '(%s or %s)' % (listexp(s[:m], t), listexp(s[m:], t))
 
     expr = pycompat.bytestr(expr)
-    ret = ''
+    ret = []
     pos = 0
     arg = 0
     while pos < len(expr):
@@ -629,24 +629,24 @@
             pos += 1
             d = expr[pos]
             if d == '%':
-                ret += d
+                ret.append(d)
             elif d in 'dsnbr':
-                ret += argtype(d, args[arg])
+                ret.append(argtype(d, args[arg]))
                 arg += 1
             elif d == 'l':
                 # a list of some type
                 pos += 1
                 d = expr[pos]
-                ret += listexp(list(args[arg]), d)
+                ret.append(listexp(list(args[arg]), d))
                 arg += 1
             else:
                 raise error.Abort(_('unexpected revspec format character %s')
                                   % d)
         else:
-            ret += c
+            ret.append(c)
         pos += 1
 
-    return ret
+    return ''.join(ret)
 
 def prettyformat(tree):
     return parser.prettyformat(tree, ('string', 'symbol'))