[C] 纯文本查看 复制代码 void send_info(uint8_t* from, uint8_t* to, uint16_t cnt)
{
uint16_t i = (cnt + 7) / 8;
switch (cnt % 8) {
case 0: do { *to++ = *from++;
case 7: *to++ = *from++;
case 6: *to++ = *from++;
case 5: *to++ = *from++;
case 4: *to++ = *from++;
case 3: *to++ = *from++;
case 2: *to++ = *from++;
case 1: *to++ = *from++;
} while (--i > 0);
}
}
来分享一段大佬写的内核高性能代码。大家都来分析下呢?优化点在哪
这个代码本意是:复制指定数量(cnt)的字节数据,从 from 缓冲区到 to 缓冲区
|