{"thread":{"id":"3241","subject":"[PATCH] Use adler32() from zlib instead of defining our own.","startedAt":"2006-02-04T22:54:01Z","lastAt":"2006-02-04T23:20:23Z","messageCount":2,"participants":["Peter Eriksen"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"15590","messageId":"20060204225401.GA24725@ebar091.ebar.dtu.dk","threadId":"3241","inReplyTo":null,"subject":"[PATCH] Use adler32() from zlib instead of defining our own.","fromName":"Peter Eriksen","fromEmail":"s022018@student.dtu.dk","sentAt":"2006-02-04T22:54:01Z","receivedAt":"2006-02-04T22:54:01Z","isPatch":true,"sender":{"key":"s022018@student.dtu.dk","avatar":null},"body":"\nSince we already depend on zlib, we don't need to define our\nown adler32().  Spotted by oprofile.\n\nSigned-off-by: Peter Eriksen <s022018@student.dtu.dk>\n\n\n---\n\n diff-delta.c |   39 +--------------------------------------\n 1 files changed, 1 insertions(+), 38 deletions(-)\n\n86557e168f581f27b6869a751a56386bbc9e5059\ndiff --git a/diff-delta.c b/diff-delta.c\nindex 890986e..c2f656a 100644\n--- a/diff-delta.c\n+++ b/diff-delta.c\n@@ -20,6 +20,7 @@\n \n #include <stdlib.h>\n #include \"delta.h\"\n+#include \"zlib.h\"\n \n \n /* block size: min = 16, max = 64k, power of 2 */\n@@ -30,44 +31,6 @@\n #define GR_PRIME 0x9e370001\n #define HASH(v, b) (((unsigned int)(v) * GR_PRIME) >> (32 - (b)))\n \t\n-/* largest prime smaller than 65536 */\n-#define BASE 65521\n-\n-/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */\n-#define NMAX 5552\n-\n-#define DO1(buf, i)  { s1 += buf[i]; s2 += s1; }\n-#define DO2(buf, i)  DO1(buf, i); DO1(buf, i + 1);\n-#define DO4(buf, i)  DO2(buf, i); DO2(buf, i + 2);\n-#define DO8(buf, i)  DO4(buf, i); DO4(buf, i + 4);\n-#define DO16(buf)    DO8(buf, 0); DO8(buf, 8);\n-\n-static unsigned int adler32(unsigned int adler, const unsigned char *buf, int len)\n-{\n-\tint k;\n-\tunsigned int s1 = adler & 0xffff;\n-\tunsigned int s2 = adler >> 16;\n-\n-\twhile (len > 0) {\n-\t\tk = MIN(len, NMAX);\n-\t\tlen -= k;\n-\t\twhile (k >= 16) {\n-\t\t\tDO16(buf);\n-\t\t\tbuf += 16;\n-\t\t\tk -= 16;\n-\t\t}\n-\t\tif (k != 0)\n-\t\t\tdo {\n-\t\t\t\ts1 += *buf++;\n-\t\t\t\ts2 += s1;\n-\t\t\t} while (--k);\n-\t\ts1 %= BASE;\n-\t\ts2 %= BASE;\n-\t}\n-\n-\treturn (s2 << 16) | s1;\n-}\n-\n static unsigned int hashbits(unsigned int size)\n {\n \tunsigned int val = 1, bits = 0;\n-- \n1.1.6.g8655\n"},{"id":"15591","messageId":"20060204232023.GA25081@ebar091.ebar.dtu.dk","threadId":"3241","inReplyTo":"20060204225401.GA24725@ebar091.ebar.dtu.dk","subject":"Re: [PATCH] Use adler32() from zlib instead of defining our own.","fromName":"Peter Eriksen","fromEmail":"s022018@student.dtu.dk","sentAt":"2006-02-04T23:20:23Z","receivedAt":"2006-02-04T23:20:23Z","isPatch":true,"sender":{"key":"s022018@student.dtu.dk","avatar":null},"body":"On Sat, Feb 04, 2006 at 11:54:01PM +0100, Peter Eriksen wrote:\n> \n> Since we already depend on zlib, we don't need to define our\n> own adler32().  Spotted by oprofile.\n\nSorry for the bad formatting, I don't use git-format-patch often enough\nto be comfortable with it yet.\n\nThe patch shows no regression on my machine and at least doesn't slow\ndown the 2.6.15 merge with 2.6.12+change, but I don't know, if it's\ncorrect.  It just seemed like an easy cleanup.\n\nIt was only spotted indirectly, while I was playing with OProfile\n(thanks Linus), trying to find the bottlenecks in the afore mentioned \nmerge.\n\nRegards,\n\nPeter\n"}]}