std.algorithm.swap and memcpy

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Mon Jul 6 08:38:26 PDT 2009


dsimcha wrote:
> I saw in the changelog that std.algorithm.swap now uses memcpy because it's
> faster than the old way.  Why is this?  If memcpy is faster, how come DMD
> doesn't generate the same instructions for normal assignment?

The problem was that the copy construction and assignment were 
previously used. Those could be intercepted and made arbitrarily costly.

Andrei



More information about the Digitalmars-d mailing list