On Fri, Jul 3, 2015 at 6:22 PM, Michael Layzell <mich...@thelayzells.com> wrote: > So the ternary actually causes an unnecessary AddRef/Release pair, neat.
Did you check whether this actually occurs in an optimized build? C++ allows temporaries to be optimized away under some circumstances, e.g., when returning a local variable. It would make a lot of sense to me if it allowed the temporary created by a ternary operator to be optimized away. > The problem here appears to be that when deciding the type of the ternary, > c++ chooses nsRefPtr<Foo>, rather than Foo*. Adding the get() makes C++ > choose the correct type for the ternary, and avoids the cast of the rvalue > reference. I think it's pretty clear that nsRefPtr<Foo> must be the type of the ternary expression. I would be rather surprised if the type of the ternary depended on what you did with the result! _______________________________________________ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform