gMorphus wrote:
[<<<snip]
Effiency: using a vector is a lot more efficient. Using the copy
function with a vector instead the memcpy is a lot _less_ efficient.
The reason is that the copy function have to copy BYTE BYTE, as opposed
to coping the whole segment at once with the memcpy.
Nothing whatsoever requires a standard vector of POD types to do so.
Also, counting the fact that the full implementation of std::copy is most
probably visible to the compiler, it is not too far fetched to assume that
in certain cases (if inlining happens) std::copy will beat the hell out of
memcpy in speed. Of course this is true as long as memcpy is not a compiler
intrinsic, in which case it may be so unpolitely fast that no code can be
faster. And of course, as Victor has pointed out, std::copy and memcpy can
just be the very same functions.
So in a short time we have given acceptable (or at least a tiny bit
convincing) arguments for std::copy being way slower than memcpy, way faster
than memcpy and the same as memcpy. Now I guess all we need is to remember
that Michael Jackson, who is not in jail and not on bail. Or Knuth. They
have placed the root of evil to a very different place than the current US
government. They were pointing out, that premature optimization is the root
of all evil. Which it may not be, but it surely is a damn dumb waste of
time guesswork to optimize code, wich has not been written yet, unknown if
it is slow or not, unknown what causes it to be slow if it is... It is as
reasonable spending of ones' time as me thinking about what should I wear on
my date with Claudia Schiffer.
Sorry for the (kinda) outburts, nothing personal. I just wanted to point
out that guesswork is evil. Especially if people believe it.