On Mon, Aug 12, 2019 at 10:14:19PM -0700, Bryce Seager van Dyk wrote:
But either way, that's going to result in a copy when the
Result is constructed (unless the compiler is really clever).
Is it the data being moved into the Result which is incurring
the copy here, or the actual Result that's being returned?
The former.
I would have thought that the data is moved into the Result
avoids a copy, then the Result itself would be moved or RVOed
(either way avoiding a copy).
The move into the result only means that we invoke move rather
than copy constructors when initializing the value stored in the
result. That's more efficient for a lot of things, but still
requires copying data from the old struct to the new one.
The return value Result is guaranteed to be optimized, though,
so you only wind up with a single copy rather than two.
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform