Closed GoogleCodeExporter closed 9 years ago
This one is suprising.
I would expect the compiler to be smart enough to only initialise the table
once, since it is "const".
Placing the table at the beginning of the file, or into the if {} should make
no difference from an allocation perspective, and, i would have expected, from
an init perspective too.
But let's check that.
Original comment by yann.col...@gmail.com
on 6 Dec 2012 at 12:58
If you make it static const, it will be put into the const data segment and
will not be initialized at all at run time.
However, that gave a small performance decrease. Putting it in the beginning of
the function was faster for some reason, even though it needs another 20
instructions or so to initialize it.
Original comment by strig...@gmail.com
on 6 Dec 2012 at 1:07
In most circumstances, data in the stack is accessed faster than data in the
heap.
It's probably a side-effect of cache-locality.
static const moves the table into the heap.
I'm still surprised though that the table would be init at each passage into
the if{}. Or that it would be specifically for 64-bits systems, and not 32-bits.
Well, anyway, the fix is easy enough.
Original comment by yann.col...@gmail.com
on 6 Dec 2012 at 1:21
The same thing happens with non static const arrays also for 32-bit.
However in this case, dec2table exists only in 64-bit mode. That's why it
affects only 64-bit.
Original comment by strig...@gmail.com
on 6 Dec 2012 at 1:23
Enhancement request.
Original comment by yann.col...@gmail.com
on 6 Dec 2012 at 1:35
Enhancement integrated into r85.
Original comment by yann.col...@gmail.com
on 11 Dec 2012 at 1:42
Original issue reported on code.google.com by
strig...@gmail.com
on 5 Dec 2012 at 8:13