lwip-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-devel] Checksum optimizations


From: Andrey Volkov
Subject: Re: [lwip-devel] Checksum optimizations
Date: Tue, 26 Feb 2008 22:43:54 +0300
User-agent: Thunderbird 2.0.0.9 (Windows/20071031)

Hello Bill!

Bill Auerbach wrote:
In the inet_chksum.c code, there are 6 occurrences of:

    while ((acc >> 16) != 0) {

      acc = (acc & 0xffffUL) + (acc >> 16);

    }

Is it not true that the loop can run a maximum of once? Wouldn’t this be slightly more efficient?

    if ((acc >> 16) != 0) {

      acc = (acc & 0xffffUL) + 1;

    }

IHMO, next code will be better, since "if" usually more expensive then arithmetic instructions.

acc = (acc & 0xffff) + (acc >> 16);


--
Regards
Andrey Volkov





reply via email to

[Prev in Thread] Current Thread [Next in Thread]