Mercurial > hg
changeset 436:6aeb4fee51f6
Optimize annotate a bit
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Optimize annotate a bit
Keep the original text around so we don't need to rejoin it
Use slice insert-in-place rather than += to construct new lists
Construct the decorated list with list multiply rather than comprehension
manifest hash: 8c0effb9777750d524d71ad3a2eade3c6ddd579e
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)
iD8DBQFCuca0ywK+sNU5EO8RAtvQAJwOViomGCtlZx/R76i8/CZGvGPqUwCfdybd
nRUv1854GjzCbfygzXfeIes=
=6Q+E
-----END PGP SIGNATURE-----
author | mpm@selenic.com |
---|---|
date | Wed, 22 Jun 2005 12:14:44 -0800 |
parents | e731d25ddab2 |
children | 5b38a5af4019 |
files | mercurial/hg.py |
diffstat | 1 files changed, 6 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/hg.py Wed Jun 22 11:31:24 2005 -0800 +++ b/mercurial/hg.py Wed Jun 22 12:14:44 2005 -0800 @@ -63,19 +63,16 @@ def annotate(self, node): def decorate(text, rev): - return [(rev, l) for l in text.splitlines(1)] - - def strip(annotation): - return "".join([e[1] for e in annotation]) + return ([rev] * len(text.splitlines()), text) def pair(parent, child): new = [] lb = 0 - for a1, a2, b1, b2 in bdiff.blocks(strip(parent), strip(child)): - new += child[lb:b1] - new += parent[a1:a2] + for a1, a2, b1, b2 in bdiff.blocks(parent[1], child[1]): + new[lb:] = child[0][lb:b1] + new[b1:] = parent[0][a1:a2] lb = b2 - return new + return (new, child[1]) # find all ancestors needed = {node:1} @@ -108,7 +105,7 @@ del hist[p] hist[n] = curr - return hist[n] + return zip(hist[n][0], hist[n][1].splitlines(1)) class manifest(revlog): def __init__(self, opener):