Mercurial > moin > 1.9
changeset 963:1083861bd16c
Replaced size literals with computed constant.
author | Alexander Schremmer <alex AT alexanderweb DOT de> |
---|---|
date | Sat, 01 Jul 2006 01:50:31 +0200 |
parents | 930c9e82a60b |
children | dede3773735c |
files | MoinMoin/util/bdiff.py |
diffstat | 1 files changed, 5 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/MoinMoin/util/bdiff.py Sat Jul 01 01:47:42 2006 +0200 +++ b/MoinMoin/util/bdiff.py Sat Jul 01 01:50:31 2006 +0200 @@ -11,6 +11,7 @@ import zlib, difflib, struct BDIFF_PATT = ">lll" +BDIFF_PATT_SIZE = struct.calcsize(">lll") def compress(text): return zlib.compress(text) # here we could tune the compression level @@ -50,8 +51,8 @@ pos = 0 t = [] while pos < len(bin): - p1, p2, l = struct.unpack(BDIFF_PATT, bin[pos:pos + 12]) - pos += 12 + p1, p2, l = struct.unpack(BDIFF_PATT, bin[pos:pos + BDIFF_PATT_SIZE]) + pos += BDIFF_PATT_SIZE t.append(bin[pos:pos + l]) pos += l return "".join(t) @@ -62,8 +63,8 @@ r = [] while pos < len(bin): - p1, p2, l = struct.unpack(BDIFF_PATT, bin[pos:pos + 12]) - pos += 12 + p1, p2, l = struct.unpack(BDIFF_PATT, bin[pos:pos + BDIFF_PATT_SIZE]) + pos += BDIFF_PATT_SIZE r.append(a[last:p1]) r.append(bin[pos:pos + l]) pos += l