Hello,
I programmed a set of functions for bit output. Trying to make my code run even faster, I came across two lines of code that looked like this:
Code:
*put_buffer |= bits >> (count - current_bit);
count -= current_bit;
I replaced it with:
Code:
count -= current_bit;
*put_buffer |= bits >> count;
And did the same for two similar pieces of code.
Than I ran my program in Time profiler (I'm coding on a Mac and using Xcode) only to find out that - on average - my program spent about 30% of time more in the function that contained the above changes.
Any ideas why that might be happening? With that three changes, I did remove three subtractions for each function call and the function was called 10,000,000 times in each of my testing runs.