既然memcpy现在应该高度优化,那么使用显式循环展开来优化Ipv6地址的副本是否仍然有意义?
#include <netinet/in.h>
struct in6_addr IP_1;
struct in6_addr IP_2;
;
;
IP2.__in6_u.__u6_addr32[0] = IP1.__in6_u.__u6_addr32[0];
IP2.__in6_u.__u6_addr32[1] = IP1.__in6_u.__u6_addr32[1];
IP2.__in6_u.__u6_addr32[2] = IP1.__in6_u.__u6_addr32[2];
IP2.__in6_u.__u6_addr32[3] = IP1.__in6_u.__u6_addr32[3];请注意,上面的代码最适合32位体系结构。
有没有我不知道的最佳实践?
发布于 2012-07-05 00:00:20
你应该只做IP2 = IP1;,让编译器来处理它。
https://stackoverflow.com/questions/11332108
复制相似问题