lwip-devel
[Top][All Lists]
Advanced

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

Re: [lwip-devel] ip6_addr_copy() ?


From: Bill Auerbach
Subject: Re: [lwip-devel] ip6_addr_copy() ?
Date: Mon, 13 Jun 2011 10:14:46 -0400

>/** Copy IPv6 address - faster than ip6_addr_set: no NULL check */
>#define ip6_addr_copy(dest, src) do{(dest).addr[0] = (src).addr[0]; \
>                                    (dest).addr[1] = (src).addr[1]; \
>                                    (dest).addr[2] = (src).addr[2]; \
>                                    (dest).addr[3] =
>(src).addr[3];}while(0)
>
>As all members of the structure are copied, why not use this instead? :
>
>dest = src;
>
>That let's the compiler do the optimization and is much more readable.
>
>Or did I overlook something?

On some platforms much better performance can be gained using a macro - a
byte inline copy could be the best way.  A struct copy as you suggest could
simply call memcpy.  The call and return has more overhead than the
operation.

Bill





reply via email to

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