summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools
diff options
context:
space:
mode:
authorRobin Burchell <robin+qt@viroteck.net>2012-04-06 16:34:19 +0200
committerQt by Nokia <qt-info@nokia.com>2012-04-11 10:46:19 +0200
commit7be255156feb7636a5cca5c4fe78f42879ffe69b (patch)
tree0255287041af5b79cb437e7d9003cd4c9a179dfc /src/corelib/tools
parent5dc506ad841685c8404c085bd8cf9c5442518897 (diff)
Deprecate qMemCopy/qMemSet in favour of their stdlib equivilents.
Just like qMalloc/qRealloc/qFree, there is absolutely no reason to wrap these functions just to avoid an include, except to pay for it with worse runtime performance. On OS X, on byte sizes from 50 up to 1000, calling memset directly is 28-15% faster(!) than adding an additional call to qMemSet. The advantage on sizes above that is unmeasurable. For qMemCopy, the benefits are a little more modest: 16-7%. Change-Id: I98aa92bb765aea0448e3f20af42a039b369af0b3 Reviewed-by: Giuseppe D'Angelo <dangelog@gmail.com> Reviewed-by: John Brooks <john.brooks@dereferenced.net> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Diffstat (limited to 'src/corelib/tools')
-rw-r--r--src/corelib/tools/qbytearraymatcher.cpp2
-rw-r--r--src/corelib/tools/qstring.h2
-rw-r--r--src/corelib/tools/qstringmatcher.cpp2
-rw-r--r--src/corelib/tools/qvarlengtharray.h4
-rw-r--r--src/corelib/tools/qvector.h4
5 files changed, 7 insertions, 7 deletions
diff --git a/src/corelib/tools/qbytearraymatcher.cpp b/src/corelib/tools/qbytearraymatcher.cpp
index a635db0a15..c69602138e 100644
--- a/src/corelib/tools/qbytearraymatcher.cpp
+++ b/src/corelib/tools/qbytearraymatcher.cpp
@@ -121,7 +121,7 @@ QByteArrayMatcher::QByteArrayMatcher()
{
p.p = 0;
p.l = 0;
- qMemSet(p.q_skiptable, 0, sizeof(p.q_skiptable));
+ memset(p.q_skiptable, 0, sizeof(p.q_skiptable));
}
/*!
diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h
index a902f5f375..4936bcec2a 100644
--- a/src/corelib/tools/qstring.h
+++ b/src/corelib/tools/qstring.h
@@ -814,7 +814,7 @@ inline QString QString::section(QChar asep, int astart, int aend, SectionFlags a
inline int QString::toWCharArray(wchar_t *array) const
{
if (sizeof(wchar_t) == sizeof(QChar)) {
- qMemCopy(array, d->data(), sizeof(QChar) * size());
+ memcpy(array, d->data(), sizeof(QChar) * size());
return size();
}
return toUcs4_helper(d->data(), size(), reinterpret_cast<uint *>(array));
diff --git a/src/corelib/tools/qstringmatcher.cpp b/src/corelib/tools/qstringmatcher.cpp
index faab7a903f..382d2e9411 100644
--- a/src/corelib/tools/qstringmatcher.cpp
+++ b/src/corelib/tools/qstringmatcher.cpp
@@ -151,7 +151,7 @@ static inline int bm_find(const ushort *uc, uint l, int index, const ushort *puc
QStringMatcher::QStringMatcher()
: d_ptr(0), q_cs(Qt::CaseSensitive)
{
- qMemSet(q_data, 0, sizeof(q_data));
+ memset(q_data, 0, sizeof(q_data));
}
/*!
diff --git a/src/corelib/tools/qvarlengtharray.h b/src/corelib/tools/qvarlengtharray.h
index 6ce6573843..639d2463fd 100644
--- a/src/corelib/tools/qvarlengtharray.h
+++ b/src/corelib/tools/qvarlengtharray.h
@@ -230,7 +230,7 @@ Q_OUTOFLINE_TEMPLATE void QVarLengthArray<T, Prealloc>::append(const T *abuf, in
while (s < asize)
new (ptr+(s++)) T(*abuf++);
} else {
- qMemCopy(&ptr[s], abuf, increment * sizeof(T));
+ memcpy(&ptr[s], abuf, increment * sizeof(T));
s = asize;
}
}
@@ -268,7 +268,7 @@ Q_OUTOFLINE_TEMPLATE void QVarLengthArray<T, Prealloc>::realloc(int asize, int a
QT_RETHROW;
}
} else {
- qMemCopy(ptr, oldPtr, copySize * sizeof(T));
+ memcpy(ptr, oldPtr, copySize * sizeof(T));
}
} else {
ptr = oldPtr;
diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h
index 3c0db06589..b36b832c26 100644
--- a/src/corelib/tools/qvector.h
+++ b/src/corelib/tools/qvector.h
@@ -418,7 +418,7 @@ QVector<T>::QVector(int asize)
while (i != b)
new (--i) T;
} else {
- qMemSet(d->begin(), 0, asize * sizeof(T));
+ memset(d->begin(), 0, asize * sizeof(T));
}
}
@@ -546,7 +546,7 @@ void QVector<T>::realloc(int asize, int aalloc)
} else if (asize > x->size) {
// initialize newly allocated memory to 0
- qMemSet(x->end(), 0, (asize - x->size) * sizeof(T));
+ memset(x->end(), 0, (asize - x->size) * sizeof(T));
}
x->size = asize;