Rev 155: Change apply_delta to tack things onto a list, instead of a string. in http://bzr.arbash-meinel.com/branches/bzr/other/dulwich/trunk
John Arbash Meinel
john at arbash-meinel.com
Mon Feb 23 16:34:15 GMT 2009
At http://bzr.arbash-meinel.com/branches/bzr/other/dulwich/trunk
------------------------------------------------------------
revno: 155
revision-id: john at arbash-meinel.com-20090223163242-6t3rhz9sfmwscfl6
parent: jelmer at samba.org-20090222222715-1b5j4j7qh4xlgktc
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: trunk
timestamp: Mon 2009-02-23 10:32:42 -0600
message:
Change apply_delta to tack things onto a list, instead of a string.
This should avoid lots of string copy overhead.
-------------- next part --------------
=== modified file 'dulwich/pack.py'
--- a/dulwich/pack.py 2009-02-22 17:00:50 +0000
+++ b/dulwich/pack.py 2009-02-23 16:32:42 +0000
@@ -706,7 +706,7 @@
"""Based on the similar function in git's patch-delta.c."""
assert isinstance(src_buf, str), "was %r" % (src_buf,)
assert isinstance(delta, str)
- out = ""
+ out = []
index = 0
delta_length = len(delta)
def pop(delta, index):
@@ -745,9 +745,9 @@
cp_off + cp_size > src_size or
cp_size > dest_size):
break
- out += src_buf[cp_off:cp_off+cp_size]
+ out.append(src_buf[cp_off:cp_off+cp_size])
elif cmd != 0:
- out += delta[index:index+cmd]
+ out.append(delta[index:index+cmd])
index += cmd
else:
raise ApplyDeltaError("Invalid opcode 0")
@@ -755,6 +755,7 @@
if index != delta_length:
raise ApplyDeltaError("delta not empty: %r" % delta[index:])
+ out = ''.join(out)
if dest_size != len(out):
raise ApplyDeltaError("dest size incorrect")
More information about the bazaar-commits
mailing list