Faster approach to checking for an all-zero buffer in C?

后端 未结 20 2403
孤独总比滥情好
孤独总比滥情好 2020-12-03 05:33

I am searching for a faster method of accomplishing this:

int is_empty(char * buf, int size) 
{
    int i;
    for(i = 0; i < size; i++) {
        if(buf[         


        
20条回答
  •  无人及你
    2020-12-03 05:38

    I think I have a good solution for this. Create a dummy zeroed array and use memcmp(). Thats what I do.

提交回复
热议问题