@matheusbsbs / matheus-bagliano / commits / 0606c36a73
Fork 0

base85: Make the code more obvious instead of explaining the non-obvious

Here is another cleanup ... Signed-off-by: Andreas Gruenbacher <agruen@suse.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Andreas Gruenbacher committed Jan 8, 2010 at 14:40 UTC 0606c36a73449e76d8f6133253c1eff291ee8c97
1 file changed +2 -8
base85.c
+2 -8
@@ -57,14 +57,8 @@ int decode_85(char *dst, const char *buffer, int len)
57 de = de85[ch];
58 if (--de < 0)
59 return error("invalid base85 alphabet %c", ch);
60 - /*
61 - * Detect overflow. The largest
62 - * 5-letter possible is "|NsC0" to
63 - * encode 0xffffffff, and "|NsC" gives
64 - * 0x03030303 at this point (i.e.
65 - * 0xffffffff = 0x03030303 * 85).
66 - */
67 - if (0x03030303 < acc ||
60 + /* Detect overflow. */
61 + if (0xffffffff / 85 < acc ||
62 0xffffffff - de < (acc *= 85))
63 return error("invalid base85 sequence %.5s", buffer-5);
64 acc += de;