I have a code that needs to check if a given buffer of size 2048 is all zero. Right now I make a single traversal but wonder if there is a faster way to check if all contain 0. Is there a faster way? The cod e I have is as follows:
static int isSilent(Uint8* buf, int length){
int i;
for(i=0; i<length; i++)
if(buf[i] != 0) return 0;
return 1;
}
EDIT: I'm doing real time audio processing thus the small buffer size and trying to reduce the delay. Just trying to explore faster ways. Thanks.