Show More
@@ -42,6 +42,13 b' def _move(m, dest, src, count):' | |||||
42 | m.seek(dest) |
|
42 | m.seek(dest) | |
43 | m.write(buf) |
|
43 | m.write(buf) | |
44 |
|
44 | |||
|
45 | def _collect(m, buf, list): | |||
|
46 | start = buf | |||
|
47 | for l, p in reversed(list): | |||
|
48 | _move(m, buf, p, l) | |||
|
49 | buf += l | |||
|
50 | return (buf - start, start) | |||
|
51 | ||||
45 | def patches(a, bins): |
|
52 | def patches(a, bins): | |
46 | if not bins: |
|
53 | if not bins: | |
47 | return a |
|
54 | return a | |
@@ -66,18 +73,11 b' def patches(a, bins):' | |||||
66 | m.seek(pos) |
|
73 | m.seek(pos) | |
67 | for p in bins: m.write(p) |
|
74 | for p in bins: m.write(p) | |
68 |
|
75 | |||
69 | def collect(buf, list): |
|
|||
70 | start = buf |
|
|||
71 | for l, p in reversed(list): |
|
|||
72 | _move(m, buf, p, l) |
|
|||
73 | buf += l |
|
|||
74 | return (buf - start, start) |
|
|||
75 |
|
||||
76 | for plen in plens: |
|
76 | for plen in plens: | |
77 | # if our list gets too long, execute it |
|
77 | # if our list gets too long, execute it | |
78 | if len(frags) > 128: |
|
78 | if len(frags) > 128: | |
79 | b2, b1 = b1, b2 |
|
79 | b2, b1 = b1, b2 | |
80 | frags = [collect(b1, frags)] |
|
80 | frags = [_collect(m, b1, frags)] | |
81 |
|
81 | |||
82 | new = [] |
|
82 | new = [] | |
83 | end = pos + plen |
|
83 | end = pos + plen | |
@@ -92,7 +92,7 b' def patches(a, bins):' | |||||
92 | last = p2 |
|
92 | last = p2 | |
93 | frags.extend(reversed(new)) # what was left at the end |
|
93 | frags.extend(reversed(new)) # what was left at the end | |
94 |
|
94 | |||
95 | t = collect(b2, frags) |
|
95 | t = _collect(m, b2, frags) | |
96 |
|
96 | |||
97 | m.seek(t[1]) |
|
97 | m.seek(t[1]) | |
98 | return m.read(t[0]) |
|
98 | return m.read(t[0]) |
General Comments 0
You need to be logged in to leave comments.
Login now