[Qt-interest] QString ot QUuid for QHash and QMap keys?

Scott Aron Bloom Scott.Bloom at onshorecs.com
Fri Oct 21 21:00:43 CEST 2011


There is a bug filed somewhere about the .toString() without curly, (I filed it 2 years ago or so)

 

That said, I am NOT convinced the QHash< QUuuid > will be faster...  the operator< for QUuid uses the 16 byte number...  for 1000 items, you are talking ~10 integer comparisons, if your hash table takes more than 10 operations to compute, the hash will be more expensive.

 

Honestly, I think the ONLY way to really do this is with a profiler, even a QTime.start/elapsed home grown one...

 

The results might surprise you

 

Scott

 

 

From: qt-interest-bounces+scott.bloom=onshorecs.com at qt.nokia.com [mailto:qt-interest-bounces+scott.bloom=onshorecs.com at qt.nokia.com] On Behalf Of Andre Somers
Sent: Friday, October 21, 2011 10:14 AM
To: qt-interest at qt.nokia.com
Subject: Re: [Qt-interest] QString ot QUuid for QHash and QMap keys?

 

Op 21-10-2011 19:08, Jason H schreef: 

I am wondering which if the following results in fastest lookups. I've got about 500-100o items in the collection, and I will constantly be doing lookups as the system gets the UUID for an object then proceeds to manipulate that object potentially several times a second, for each object.

QMap<QUuid, QObject*>

QHash<QUuid, QObject*>

QMap<QString, QObject*>

QHash<QString, QObject*>

 

Where the string keys are a QUuid::toString().mid(1,36) (trims the curley braces).

 

Also, why isn't there a toString() version that will just give me a string without the braces? I keep making Uuids, converting them to strings and cutting the braces off. 

 

Thanks.

The QHash versions are going to be faster than the QMap ones, but I am not sure which of the hashes will be faster. I guess the QUuid one, but that would be easy enough to benchmark, right?

André

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20111021/0b07446f/attachment.html 


More information about the Qt-interest-old mailing list