Mercurial > hg
changeset 9413:a5adf55ee533
manifest.add(): simplify with iterators and generator expressions
author | Benoit Boissinot <benoit.boissinot@ens-lyon.org> |
---|---|
date | Wed, 02 Sep 2009 20:18:35 +0200 |
parents | 3a78bbc57660 |
children | 65dc516363ee |
files | mercurial/manifest.py |
diffstat | 1 files changed, 5 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/manifest.py Sat Aug 29 00:30:03 2009 +0200 +++ b/mercurial/manifest.py Wed Sep 02 20:18:35 2009 +0200 @@ -110,17 +110,13 @@ def addlistdelta(addlist, x): # start from the bottom up # so changes to the offsets don't mess things up. - i = len(x) - while i > 0: - i -= 1 - start = x[i][0] - end = x[i][1] - if x[i][2]: - addlist[start:end] = array.array('c', x[i][2]) + for start, end, content in reversed(x): + if content: + addlist[start:end] = array.array('c', content) else: del addlist[start:end] - return "".join([struct.pack(">lll", d[0], d[1], len(d[2])) + d[2] - for d in x ]) + return "".join(struct.pack(">lll", start, end, len(content)) + content + for start, end, content in x) def checkforbidden(l): for f in l: