Patchwork [1,of,2] statprof: cleanup string construction

login
register
mail settings
Submitter Boris Feld
Date July 16, 2018, 8:59 a.m.
Message ID <eabea66333aa934d8a8f.1531731597@FB-lair>
Download mbox | patch
Permalink /patch/32855/
State Accepted
Headers show

Comments

Boris Feld - July 16, 2018, 8:59 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 eabea66333aa934d8a8f0fc68633a72623a0864b
# Parent  3700564c63fee7b26ca948e75dee2ea631b1dd4e
# EXP-Topic cleanupstat
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r eabea66333aa
statprof: cleanup string construction

Use string substitutions instead of string additions.
Yuya Nishihara - July 16, 2018, 9:44 a.m.
On Mon, 16 Jul 2018 10:59: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 eabea66333aa934d8a8f0fc68633a72623a0864b
> # Parent  3700564c63fee7b26ca948e75dee2ea631b1dd4e
> # EXP-Topic cleanupstat
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r eabea66333aa
> statprof: cleanup string construction
> 
> Use string substitutions instead of string additions.
> 
> 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\05%s\n" % (time, '\0'.join(sites)))

\05 ?

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\05%s\n" % (time, '\0'.join(sites)))
 
 def load_data(path):
     lines = open(path, 'r').read().splitlines()