Re: PSA: mozilla::Result is about to understand move semantics

2019-08-13 Thread Kris Maglione
Just for some additional extra context... The C++ mozilla::Result implementation is pretty heavily optimized for common use cases to try to pack its representation into a single machine word when possible. For instance, if you return a `Result`, you're really just returning an `nsresult`. If

Re: PSA: mozilla::Result is about to understand move semantics

2019-08-13 Thread Alexis Beingessner
Just chiming in here with some brief extra context on the performance of Result (which I really need to do a writeup about so that I can just link it): TL;DR performance of Result is usually fine, but can randomly be a huge problem. However there's also improvements for this on the (distant)

Re: PSA: mozilla::Result is about to understand move semantics

2019-08-13 Thread Kris Maglione
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

Re: PSA: mozilla::Result is about to understand move semantics

2019-08-12 Thread Bryce Seager van Dyk
Thanks both for the clarifications. There is a use case that I'd like to clarify the performance + sanity of. I hope discussion here will be useful to others looking to use Result, but please let me know if it's more suitable to take elsewhere. In the Media stack I often want to return a

Re: PSA: mozilla::Result is about to understand move semantics

2019-08-12 Thread Kris Maglione
On Mon, Aug 12, 2019 at 11:16:17PM +0200, Emilio Cobos Álvarez wrote: On 8/12/19 10:38 PM, Bryce Seager van Dyk wrote: On Monday, August 12, 2019 at 8:41:26 AM UTC-7, Emilio Cobos Álvarez wrote: Neat! Thanks for doing this. It should allow for broader use of Result in media code. Are there

Re: PSA: mozilla::Result is about to understand move semantics

2019-08-12 Thread Emilio Cobos Álvarez
On 8/12/19 10:38 PM, Bryce Seager van Dyk wrote: On Monday, August 12, 2019 at 8:41:26 AM UTC-7, Emilio Cobos Álvarez wrote: Neat! Thanks for doing this. It should allow for broader use of Result in media code. Are there any footguns to watch out for when moving into the Result? Looking at

Re: PSA: mozilla::Result is about to understand move semantics

2019-08-12 Thread Bryce Seager van Dyk
On Monday, August 12, 2019 at 8:41:26 AM UTC-7, Emilio Cobos Álvarez wrote: > If you don't use mozilla::Result, then you can stop reading now. > > Result always returned the ok / errors by value. That's fine when the ok > or error values are cheap / small, like integers, but over time we've >

PSA: mozilla::Result is about to understand move semantics

2019-08-12 Thread Emilio Cobos Álvarez
If you don't use mozilla::Result, then you can stop reading now. Result always returned the ok / errors by value. That's fine when the ok or error values are cheap / small, like integers, but over time we've been using Result> / Result / Result, etc. Furthermore Result never worked with