Patchwork [V2] statprof: cleanup string construction

login
register
mail settings
Submitter Boris Feld
Date Aug. 14, 2018, 9:46 a.m.
Message ID <c4f06c80b89fe473ca5e.1534240017@FB-lair>
Download mbox | patch
Permalink /patch/33712/
State Accepted
Headers show

Comments

Boris Feld - Aug. 14, 2018, 9:46 a.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1527845766 -7200
#      Fri Jun 01 11:36:06 2018 +0200
# Node ID c4f06c80b89fe473ca5e3b704652c96068424c5f
# Parent  faea9b1980d9b0c97f3e457b5f271248fcd63716
# EXP-Topic cleanupstat
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r c4f06c80b89f
statprof: cleanup string construction

Use string substitutions instead of string additions.
Yuya Nishihara - Aug. 14, 2018, 11:04 p.m.
On Tue, 14 Aug 2018 11:46:57 +0200, Boris Feld wrote:
> # HG changeset patch
> # User Boris Feld <boris.feld@octobus.net>
> # Date 1527845766 -7200
> #      Fri Jun 01 11:36:06 2018 +0200
> # Node ID c4f06c80b89fe473ca5e3b704652c96068424c5f
> # Parent  faea9b1980d9b0c97f3e457b5f271248fcd63716
> # EXP-Topic cleanupstat
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r c4f06c80b89f
> statprof: cleanup string construction

Queued, thanks.

Patch

diff --git a/mercurial/statprof.py b/mercurial/statprof.py
--- a/mercurial/statprof.py
+++ b/mercurial/statprof.py
@@ -356,7 +356,7 @@  def save_data(path):
             stack = sample.stack
             sites = ['\1'.join([s.path, str(s.lineno), s.function])
                      for s in stack]
-            file.write(time + '\0' + '\0'.join(sites) + '\n')
+            file.write("%s\0%s\n" % (time, '\0'.join(sites)))
 
 def load_data(path):
     lines = open(path, 'r').read().splitlines()