[PATCH 5/5] checksum: Optimize first addition.

Joakim Tjernlund Joakim.Tjernlund at transmode.se
Sun Apr 25 11:41:22 CEST 2010


The first add op. adds two 16 bit nums which cannot overflow
one 32 bits receiver so use plain addition instead.

Signed-off-by: Joakim Tjernlund <Joakim.Tjernlund at transmode.se>
---
 lib/checksum.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/lib/checksum.c b/lib/checksum.c
index 7b183d9..ae759d7 100644
--- a/lib/checksum.c
+++ b/lib/checksum.c
@@ -59,7 +59,7 @@ ipsum_calc_block(u16 *buf, unsigned len, u16 sum)
 
   acc_sum = sum;
   if ((u32) buf & 2) {		/* Align to 32-bit boundary */
-      add32(acc_sum, *buf++);
+      acc_sum += *buf++; /* two 16 bit numbers cannot overflow 32 bits */
       len =- 2;
   }
   rest = len & 1;
-- 
1.6.4.4




More information about the Bird-users mailing list