|
Boost : |
From: Reece Dunn (msclrhd_at_[hidden])
Date: 2005-09-28 11:00:48
Robert Ramey wrote:
> > Is there any reason why it was done this way? For threading issues?
>
>LOL, it is done that way because
>
>a) that was the first way it occurred to me to do it
>b) it worked
>c) it didn't occur to me when I wrote it that there might be a performance
>issue
>
>Of course, now that you mention it ...
>
>My first inclination would be to use
>
>const unsigned char lookup_table[] = { ...
>
>Though I'm not sure that every compiler will exploit the const-ness to
>avoid
>re-initalizing lookup_table[] every time.
What about:
static const unsigned char lookup_table[] = { ... };
The static tells the compiler that this is a global constant and not just
related to this call of the function. The const tells the compiler that the
data isn't (shouldn't be) modified.
I think this will work on all compilers. (Compare this with declaring
class-based constants using "static const ...").
- Reece
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk