# HG changeset patch # User Eugene Baranov # Date 2015-07-29 23:58:05 # Node ID 97a9f76020143e459b6cd8f0cb939f36d784e468 # Parent 9de443515f1dea6e5fdee375d82a2c1434a85995 convert: when getting file from Perforce concatenate data at the end As it turned out, even when getting relatively small files, concatenating string data every time when new chunk is received is very inefficient. Maintaining a string list of data chunks and concatenating everything in one go at the end seems much more efficient - in my testing it made getting 40 MB file 7 times faster, whilst converting of a particularly big changelist with some big files went down from 20 hours to 3 hours. diff --git a/hgext/convert/p4.py b/hgext/convert/p4.py --- a/hgext/convert/p4.py +++ b/hgext/convert/p4.py @@ -216,7 +216,7 @@ class p4_source(converter_source): stdout = util.popen(cmd, mode='rb') mode = None - contents = "" + contents = [] keywords = None for d in loaditer(stdout): @@ -252,7 +252,7 @@ class p4_source(converter_source): keywords = self.re_keywords elif code == "text" or code == "binary": - contents += data + contents.append(data) lasterror = None @@ -262,6 +262,8 @@ class p4_source(converter_source): if mode is None: return None, None + contents = ''.join(contents) + if keywords: contents = keywords.sub("$\\1$", contents) if mode == "l" and contents.endswith("\n"):