Fastest way to convert bytes to unsigned int
问题 I have an array of bytes ( unsigned char * ) that must be converted to integer. Integers are represented over three bytes. This is what I have done //bytes array is allocated and filled //allocating space for intBuffer (uint32_t) unsigned long i = 0; uint32_t number; for(; i<size_tot; i+=3){ uint32_t number = (bytes[i]<<16) | (bytes[i+1]<<8) | bytes[i+2]; intBuffer[number]++; } This piece of code does its jobs well but it is incredibly slow due to the three accesses in memory (especially for