Fastest way to convert bytes to unsigned int
<p>I have an array of bytes (<code>unsigned char *</code>) that must be converted to integer. Integers are represented over three bytes. This is what I have done</p>

<pre><code>//bytes array is allocated and filled
//allocating space for intBuffer (uint32_t)
unsigned long i = 0;
uint32_t number;
for(; i&lt;size_tot; i+=3){
    uint32_t number = (bytes[i]&lt;&lt;16) | (bytes[i+1]&lt;&lt;8) | bytes[i+2];
    intBuffer[number]++;
}
</code></pre>

<p>This piece of code does its jobs well but it is incredibly slow due to the three accesses in memory (especially for big values of <code>size_tot</code>, in the order of <code>3000000</code>). Is there a way to do it faster and increase performance?</p>