On Thu, 2010-08-19 at 11:58 -0700, Roland McGrath wrote:
> > +       _base::push_back (*first != NULL ? std::string (*first) : "");
> > +       _base::insert (_base::end (), ++first, other.end ());
> 
> I'll mention some C++ arcana you might not have noticed here.  We just
> don't care about the microoptimization details right here, but for
> future reference.  
> 
> The type of:
>       (*first != NULL ? std::string (*first) : "")
> is std::string.  So really it's doing:
>       (*first != NULL ? std::string (*first) : std::string (""))
> by implicit type coercion.  Hence, you might as well write:
>       std::string (*first ?: "")
> to do that.
> 
> But, here (I think!) you can pass a const char * to push_back instead.
> i.e.
>       _base::push_back (*first ?: "");
> If that does work, then I think it may well avoid a copy-construct+destruct
> of a temporary std::string object.

Thanks for noticing. Yes, that is, in retrospect, obviously the right
thing to do. Please do let me know if you see me doing silly stuff like
that, even if it isn't critical. Then hopefully I won't do it when it
does become critical.

Thanks,

Mark

_______________________________________________
elfutils-devel mailing list
[email protected]
https://fedorahosted.org/mailman/listinfo/elfutils-devel

Reply via email to