##// END OF EJS Templates
pure mpatch: avoid using list.insert(0, ...)...
Dan Villiom Podlaski Christiansen -
r14065:8f7132fa default
parent child Browse files
Show More
@@ -56,9 +56,9 b' def patches(a, bins):'
56
56
57 def pull(dst, src, l): # pull l bytes from src
57 def pull(dst, src, l): # pull l bytes from src
58 while l:
58 while l:
59 f = src.pop(0)
59 f = src.pop()
60 if f[0] > l: # do we need to split?
60 if f[0] > l: # do we need to split?
61 src.insert(0, (f[0] - l, f[1] + l))
61 src.append((f[0] - l, f[1] + l))
62 dst.append((l, f[1]))
62 dst.append((l, f[1]))
63 return
63 return
64 dst.append(f)
64 dst.append(f)
@@ -66,7 +66,7 b' def patches(a, bins):'
66
66
67 def collect(buf, list):
67 def collect(buf, list):
68 start = buf
68 start = buf
69 for l, p in list:
69 for l, p in reversed(list):
70 move(buf, p, l)
70 move(buf, p, l)
71 buf += l
71 buf += l
72 return (buf - start, start)
72 return (buf - start, start)
@@ -88,7 +88,7 b' def patches(a, bins):'
88 new.append((l, pos + 12)) # what got added
88 new.append((l, pos + 12)) # what got added
89 pos += l + 12
89 pos += l + 12
90 last = p2
90 last = p2
91 frags = new + frags # what was left at the end
91 frags.extend(reversed(new)) # what was left at the end
92
92
93 t = collect(b2, frags)
93 t = collect(b2, frags)
94
94
General Comments 0
You need to be logged in to leave comments. Login now