[cfe-commits] [libcxx] r135893 - /libcxx/trunk/include/string

Benjamin Kramer benny.kra at googlemail.com
Mon Jul 25 11:41:41 PDT 2011


On Mon, Jul 25, 2011 at 11:28, Howard Hinnant <hhinnant at apple.com> wrote:
> On Jul 25, 2011, at 2:21 PM, Benjamin Kramer wrote:
>> Wouldn't it be faster to compare sizes first and do the data
>> comparison only if sizes are equal? I suppose traits_type::compare is
>> the expensive part of this function.
>
> This function has a 3-way result:
>
> 1. r < 0 if *this < __str
> 2. r == 0 if *this == __str
> 3. r > 0 if *this > __str
>
> For cases 1 and 3, traits_type::compare must be called even if size() != __str.size().  I'm unsure how to proceed with your suggestion.

I was under the impression that traits_type::compare was unnecessary
in cases 1. and 3.
Sorry for the noise.

- Ben




More information about the cfe-commits mailing list