Boost logo

Boost :

From: Giovanni Piero Deretta (gpderetta_at_[hidden])
Date: 2008-02-15 13:01:09

On Fri, Feb 15, 2008 at 6:54 PM, Phil Endecott
<spam_from_boost_dev_at_[hidden]> wrote:
> Giovanni Piero Deretta wrote:
> > On Thu, Feb 14, 2008 at 6:50 PM, Phil Endecott
> > <spam_from_boost_dev_at_[hidden]> wrote:
> >> In each case, I've used the predicate with std::find_if. But if I
> >> instead use C's strcspn() to do the whole job, I see a relative
> >> performance for this example of 20. I find it depressing that the C++
> >> code doesn't come close to that.
> >
> > Well, it is not really a fair comparison, the 'C' function is likely
> > implemented in hand optimized assembler, (
> > and for such a small function, humans are still better than compilers.
> > So it isn't really C++ versus C. Also the C version is not generic at
> > all.
> Hi Giovanni,
> I can't agree with that. There's no reason why the C++ implementation
> couldn't be written in hand-optimised assembler too. Or it could
> simply call the fast C function:

Actually we are in agreement :). Of course the C++ version (or
specializations of that) can be implemented in hand tuned assembler, I
was just pointing out that the difference in speed wasn't due to
language 'power', but just implementation details. There is no reason
that the C++ interface to be slower to the C one (in fact you have
shown that, by using compile time knowledge, a plain C++ version can
even beat the assembler code).


Boost list run by bdawes at, gregod at, cpdaniel at, john at