summaryrefslogtreecommitdiffstats
path: root/src/tools/qstring.cpp
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-12-17 02:40:59 -0600
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-12-17 02:40:59 -0600
commiteced6bf82ec7c5e67c0917e4c52e8389e8d7c831 (patch)
tree4b803066c2ffeb47ea064749eb9e20bc29a5c9b0 /src/tools/qstring.cpp
parent1ee1ffbae69dc78721af139f0794628571fd35ef (diff)
downloadqt3-eced6bf82ec7c5e67c0917e4c52e8389e8d7c831.tar.gz
qt3-eced6bf82ec7c5e67c0917e4c52e8389e8d7c831.zip
Reduce TQString allocation/deallocation load in populateControlElementDataFromWidget
Remove unneeded mutex locks around certain TQString operations
Diffstat (limited to 'src/tools/qstring.cpp')
-rw-r--r--src/tools/qstring.cpp73
1 files changed, 20 insertions, 53 deletions
diff --git a/src/tools/qstring.cpp b/src/tools/qstring.cpp
index 251637d..014dc23 100644
--- a/src/tools/qstring.cpp
+++ b/src/tools/qstring.cpp
@@ -1048,13 +1048,9 @@ QStringData::QStringData() : QShared(),
islatin1(FALSE),
security_unpaged(FALSE) {
#ifdef QT_THREAD_SUPPORT
- mutex = new QMutex( TRUE );
- mutex->lock();
+ mutex = new QMutex(FALSE);
#endif // QT_THREAD_SUPPORT
ref();
-#ifdef QT_THREAD_SUPPORT
- mutex->unlock();
-#endif // QT_THREAD_SUPPORT
}
QStringData::QStringData(QChar *u, uint l, uint m) : QShared(),
@@ -1066,7 +1062,7 @@ QStringData::QStringData(QChar *u, uint l, uint m) : QShared(),
islatin1(FALSE),
security_unpaged(FALSE) {
#ifdef QT_THREAD_SUPPORT
- mutex = new QMutex( TRUE );
+ mutex = new QMutex(FALSE);
#endif // QT_THREAD_SUPPORT
}
@@ -1494,13 +1490,6 @@ QString::QString() :
d(0)
{
d = shared_null ? shared_null : makeSharedNull();
-#ifdef QT_THREAD_SUPPORT
- d->mutex->lock();
-#endif // QT_THREAD_SUPPORT
- d->ref();
-#ifdef QT_THREAD_SUPPORT
- d->mutex->unlock();
-#endif // QT_THREAD_SUPPORT
}
/*!
@@ -1519,15 +1508,15 @@ QString::QString( QChar ch )
QString::QString( const QString &s ) :
d(s.d)
{
+ if (d != shared_null) {
#ifdef QT_THREAD_SUPPORT
- d->mutex->lock();
+ d->mutex->lock();
#endif // QT_THREAD_SUPPORT
-
- d->ref();
-
+ d->ref();
#ifdef QT_THREAD_SUPPORT
- d->mutex->unlock();
+ d->mutex->unlock();
#endif // QT_THREAD_SUPPORT
+ }
}
/*!
@@ -1550,13 +1539,6 @@ QString::QString( int size, bool /*dummy*/ )
d = new QStringData( uc, 0, l );
} else {
d = shared_null ? shared_null : (shared_null=new QStringData);
-#ifdef QT_THREAD_SUPPORT
- d->mutex->lock();
-#endif // QT_THREAD_SUPPORT
- d->ref();
-#ifdef QT_THREAD_SUPPORT
- d->mutex->unlock();
-#endif // QT_THREAD_SUPPORT
}
}
@@ -1598,13 +1580,6 @@ QString::QString( const QChar* unicode, uint length )
{
if ( !unicode && !length ) {
d = shared_null ? shared_null : makeSharedNull();
-#ifdef QT_THREAD_SUPPORT
- d->mutex->lock();
-#endif // QT_THREAD_SUPPORT
- d->ref();
-#ifdef QT_THREAD_SUPPORT
- d->mutex->unlock();
-#endif // QT_THREAD_SUPPORT
}
else {
QChar* uc = QT_ALLOC_QCHAR_VEC( length );
@@ -1689,22 +1664,19 @@ QString::~QString()
}
#endif
+ if (d == shared_null) {
+ return;
+ }
+
#ifdef QT_THREAD_SUPPORT
d->mutex->lock();
#endif // QT_THREAD_SUPPORT
if ( d->deref() ) {
- if ( d != shared_null ) {
#ifdef QT_THREAD_SUPPORT
- d->mutex->unlock();
-#endif // QT_THREAD_SUPPORT
- d->deleteSelf();
- d = NULL;
- }
- else {
-#ifdef QT_THREAD_SUPPORT
- d->mutex->unlock();
+ d->mutex->unlock();
#endif // QT_THREAD_SUPPORT
- }
+ d->deleteSelf();
+ d = NULL;
}
else {
#ifdef QT_THREAD_SUPPORT
@@ -1730,7 +1702,7 @@ void QString::real_detach()
void QString::deref()
{
- if ( d ) {
+ if ( d && (d != shared_null) ) {
#ifdef QT_THREAD_SUPPORT
d->mutex->lock();
#endif // QT_THREAD_SUPPORT
@@ -1788,13 +1760,15 @@ void QStringData::deleteSelf()
*/
QString &QString::operator=( const QString &s )
{
+ if (s.d != shared_null) {
#ifdef QT_THREAD_SUPPORT
- s.d->mutex->lock();
+ s.d->mutex->lock();
#endif // QT_THREAD_SUPPORT
- s.d->ref();
+ s.d->ref();
#ifdef QT_THREAD_SUPPORT
- s.d->mutex->unlock();
+ s.d->mutex->unlock();
#endif // QT_THREAD_SUPPORT
+ }
deref();
d = s.d;
@@ -6527,13 +6501,6 @@ QString& QString::setUnicode( const QChar *unicode, uint len )
if ( d != shared_null ) { // beware of nullstring being set to nullstring
deref();
d = shared_null ? shared_null : makeSharedNull();
-#ifdef QT_THREAD_SUPPORT
- d->mutex->lock();
-#endif // QT_THREAD_SUPPORT
- d->ref();
-#ifdef QT_THREAD_SUPPORT
- d->mutex->unlock();
-#endif // QT_THREAD_SUPPORT
}
}
else {