On Friday, 30 de September de 2011 14:37:10 Kent Hansen wrote:
> > Also, appending with QLatin1String currently do not do the sse2
> > fromLatin1, it would be trivial do so by extracting the fromLatin1 code
> > to a helper helper function.
> 
> So appending QLatin1String can be made faster?! That's horrible news, we
> want QStringLiteral to beat it massively, remember :P

Heh, talk about "adjusting the data"...

Anyway, let me give you another argument: yes, you can make QString::append 
faster for QLatin1String. You can also make QString::prepend faster. And you 
can make QString::indexOf, QString::startsWith, QString::endsWith, etc. 

The point being: QLatin1String is an *additional* code path we'd need to 
optimise. If we can instead use the same codepath that is already optimal, 
it's probably better.

> >> Now, the not-so-good news: operator==(QString) is a bit (just a bit)
> >> slower than operator==(QLatin1String) for short strings.
> >> It seems that, for short strings, the overhead of calling qMemEquals()
> >> and performing its "housecleaning chores" outweigh the benefits of its
> >> fast comparison loop.
> > 
> > It would be nice to compare with different lenght AND different on the
> > first char.
> > Or better, with actual data extracted form a qDebug in the operator== for
> > a
> > random application.
> 
> Lots of good ideas here, please update the benchmark and pass it around :D

Different-length comparison means qMemEquals isn't even called. Given that 
QLatin1String carries the length just like QString (QStringLiteral) does, 
those will have the exact same time.

The question of comparison time is only for same-length. Note that includes 
startsWith and endsWith.

> Yeah. On a related note, I replaced as many QLatin1Strings by
> QStringLiteral in QtCore as possible, and the library size increase was
> 1% (40K) on ia32.

I've got the same commit. It's a trivial increase.

The only drawback is that, due to a bug in gcc 4.6, the read-only data 
initialised by a constexpr is placed in .data instead of .rodata. GCC 4.7 has 
that fixed.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel Open Source Technology Center
      PGP/GPG: 0x6EF45358; fingerprint:
      E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358

Attachment: signature.asc
Description: This is a digitally signed message part.

_______________________________________________
Qt5-feedback mailing list
[email protected]
http://lists.qt.nokia.com/mailman/listinfo/qt5-feedback

Reply via email to