[cfe-dev] [PATCH] Add APValue::swap

Richard Smith richard at metafoo.co.uk
Wed Mar 7 17:15:07 PST 2012


On Wed, Mar 7, 2012 at 3:05 PM, Daniel Dunbar <daniel at zuster.org> wrote:

> Here is a patch which adds APValue::swap and uses it.
>
> I'm not sure I like it, anyone else have an opinion for putting it in or
> not?
>

This was actually something I was intending to investigate soon. A few
thoughts:

I'd prefer to see operator= changed as follows, all the code which says
'foo = APValue(...);' left alone:

APValue &operator=(APValue RHS) {
  swap(RHS);
  return *this;
}

Copy elision will do the rest. I'd then prefer to see copy_from killed,
with the implementation moved to APValue's copy constructor (which should
then be out-of-line).

Do you have any performance numbers for this?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20120307/1dbc7e1f/attachment.html>


More information about the cfe-dev mailing list