Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ogoffart@oscar demos]$ ./textedit/textedit
- HASH stat: total=1024 dup=678
- STRING stat: total=53616 hashed=344
- [ogoffart@oscar demos]$ ./textedit/textedit
- HASH stat: total=5132 dup=4072
- STRING stat: total=101315 hashed=1057
- [ogoffart@oscar demos]$ qmlviewer
- Qml debugging is enabled. Only use this in a safe environment!
- HASH stat: total=5341 dup=3989
- STRING stat: total=70257 hashed=1323
- [ogoffart@oscar demos]$ qmlviewer
- Qml debugging is enabled. Only use this in a safe environment!
- HASH stat: total=1691 dup=732
- STRING stat: total=14373 hashed=930
- [ogoffart@oscar demos]$ ./browser/browser
- HASH stat: total=2951 dup=1080
- STRING stat: total=111836 hashed=1870
- diff --git a/src/corelib/tools/qhash.cpp b/src/corelib/tools/qhash.cpp
- index f43e888..bfd34dd 100644
- --- a/src/corelib/tools/qhash.cpp
- +++ b/src/corelib/tools/qhash.cpp
- @@ -94,8 +94,22 @@ uint qHash(const QByteArray &key)
- return hash(reinterpret_cast<const uchar *>(key.constData()), key.size());
- }
- +
- +#include <iostream>
- +
- uint qHash(const QString &key)
- {
- + struct Stat {
- + QBasicAtomicInt count;
- +// QBasicAtomicInt simple;
- + QBasicAtomicInt dup;
- + ~Stat() { std::cout <<"HASH stat: total=" << int(count) << " dup=" << int(dup) << std::endl; }
- + };
- + static Stat s = {0, 0};
- + s.count.ref();
- + if (key.asciicache())
- + s.dup.ref();
- + key.setAsciicache();
- return hash(key.unicode(), key.size());
- }
- diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp
- index ee45cfd..71e33e5 100644
- --- a/src/corelib/tools/qstring.cpp
- +++ b/src/corelib/tools/qstring.cpp
- @@ -1219,9 +1219,22 @@ QString::QString(QChar ch)
- \internal
- */
- +#include <iostream>
- // ### Qt 5: rename freeData() to avoid confusion. See task 197625.
- void QString::free(Data *d)
- {
- +
- + struct Stat {
- + QBasicAtomicInt count;
- + // QBasicAtomicInt simple;
- + QBasicAtomicInt hash;
- + ~Stat() { std::cout <<"STRING stat: total=" << int(count) << " hashed=" << int(hash) << std::endl; }
- + };
- + static Stat s = {0, 0};
- + s.count.ref();
- + if (d->asciiCache)
- + s.hash.ref();
- +
- #ifdef QT3_SUPPORT
- if (d->asciiCache) {
- Q_ASSERT(asciiCache);
- diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h
- index bf0a0ad..9c82029 100644
- --- a/src/corelib/tools/qstring.h
- +++ b/src/corelib/tools/qstring.h
- @@ -590,6 +590,10 @@ public:
- QString(int size, Qt::Initialization);
- + bool asciicache() const { return d->asciiCache; }
- + void setAsciicache() const { const_cast<Data *>(d)->asciiCache = 1; }
- +
- +
- private:
- #if defined(QT_NO_CAST_FROM_ASCII) && !defined(Q_NO_DECLARED_NOT_DEFINED)
- QString &operator+=(const char *s);
- @@ -600,6 +604,7 @@ private:
- QString &operator=(const QByteArray &a);
- #endif
- +
- struct Data {
- QBasicAtomicInt ref;
- int alloc, size;
- @@ -712,7 +717,7 @@ inline QChar *QString::data()
- inline const QChar *QString::constData() const
- { return reinterpret_cast<const QChar*>(d->data); }
- inline void QString::detach()
- -{ if (d->ref != 1 || d->data != d->array) realloc(); }
- +{ if (d->ref != 1 || d->data != d->array) realloc(); else if (d->ref==1) d->asciiCache = 0; }
- inline bool QString::isDetached() const
- { return d->ref == 1; }
- inline QString &QString::operator=(const QLatin1String &s)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement