|
Boost : |
From: Yuval Ronen (ronen_yuval_at_[hidden])
Date: 2005-12-11 04:30:41
Larry Evans wrote:
> On 12/10/2005 09:09 AM, Yuval Ronen wrote:
>
>>One point in favour of array, is that it ensures us of O(1) lookup time.
>>A good compiler might do that with switch/case but I'm not sure it's
>>something that we can rely on.
>
> Actually, Andy Little did a comparison which showed the switch was
> faster than the array:
>
> http://groups.google.com/group/comp.lang.c++.moderated/msg/6de73412e552c387
I'm not really sure, but I have feeling the switch/case advantage is
marginal (am I right?). And another thing I'm not sure of is whether
this must be the case with all compilers. If not, then I think I prefer
a good algorithm to relying on compiler optimization which might not be
so good in compilers other than those tested in this test.
But that's just me...
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk