netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] - trivial - Improve appletalk checksum calculation
@ 2007-10-22 19:36 Joe Perches
  2007-10-23  0:35 ` David Miller
  2007-10-23  3:30 ` Stephen Hemminger
  0 siblings, 2 replies; 11+ messages in thread
From: Joe Perches @ 2007-10-22 19:36 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo; +Cc: netdev, David S. Miller

It's a bit after 2.6.1 now...

Removes unnecessary if, uses 16 bit rotate left.
Performance improves ~30%

Signed-off-by: Joe Perches <joe@perches.com>

diff --git a/net/appletalk/ddp.c b/net/appletalk/ddp.c
index 7c0b515..1c50f4c 100644
--- a/net/appletalk/ddp.c
+++ b/net/appletalk/ddp.c
@@ -925,15 +925,9 @@ static int atrtr_ioctl(unsigned int cmd, void __user *arg)
 static unsigned long atalk_sum_partial(const unsigned char *data,
 				       int len, unsigned long sum)
 {
-	/* This ought to be unwrapped neatly. I'll trust gcc for now */
 	while (len--) {
-		sum += *data;
-		sum <<= 1;
-		if (sum & 0x10000) {
-			sum++;
-			sum &= 0xffff;
-		}
-		data++;
+		sum += *data++;
+		sum = ((sum & 0x8000)>>15) | ((sum & 0x7fff)<<1);
 	}
 	return sum;
 }



^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2007-10-29  2:41 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-22 19:36 [PATCH] - trivial - Improve appletalk checksum calculation Joe Perches
2007-10-23  0:35 ` David Miller
2007-10-23  1:36   ` Joe Perches
2007-10-23  1:43     ` David Miller
2007-10-23  1:53       ` Joe Perches
2007-10-23  3:51         ` Herbert Xu
2007-10-28 20:18           ` Urs Thuermann
2007-10-28 21:01             ` Joe Perches
2007-10-29  2:40               ` Joe Perches
2007-10-23  3:30 ` Stephen Hemminger
2007-10-23  3:39   ` Joe Perches

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).