On Fri, Mar 13, 2015 at 10:54 AM, Seth Fowler <s...@mozilla.com> wrote:

>
> > On Mar 13, 2015, at 6:14 AM, Eric Rescorla <e...@rtfm.com> wrote:
> >
> > Sorry if this is a dumb question, but it seems like std::pair is fairly
> widely used in our
> > code base. Can you explain the circumstances in which you think we
> should be
> > using mozilla::Pair instead?
>
> It’s not at all a dumb question. This came up on IRC every time
> mozilla::Pair came up, so a lot of people are wondering about this.
>
> I’m not the person that originally introduced mozilla::Pair, so I wouldn’t
> consider my answer to this question definitive, but I’ll give it a shot
> anyway.
>
> mozilla::Pair is about avoiding implementation quality issues with
> std::pair. There are two quality issues in particular that have bit us in
> the past:
>
> - Poor packing, particularly when one of the types stored in the pair has
> no members. In that situation the empty type should consume no space, but
> std::pair implementations sometimes don’t handle that case efficiently.
>
> - Poor or non-existent support for move semantics. I don’t know
> specifically about the case of std::pair, but this is still biting people
> with other STL containers quite recently. Obviously the same code can have
> significantly different performance characteristics in some cases depending
> on move semantics support, so this is a serious problem.
>
> Until we know that we can rely on high quality std::pair implementations
> everywhere, my recommendation would be to always use mozilla::Pair.


I'm not sure I want to get in a long argument about this, but I'm not
convinced
this is good advice.

Just looking at dxr shows a really large number of uses of std::pair,
especially in
pieces of code that we don't control, and no uses of mozilla::Pair() other
than those in the
test code and mfbt itself [0] So I would suggest that we've already largely
incurred
those costs, whatever they are. Which platforms do you believe have these
issues?

Given the current situation, and absent some evidence that this is actually
causing
real problems in the field, it seems like there's a huge amount of benefit
in using
standard constructs.

-Ekr

[0]
https://dxr.mozilla.org/mozilla-central/search?q=%2Btype-ref%3Amozilla%3A%3APair
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to