summaryrefslogtreecommitdiffstats
path: root/src/corelib/global
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/global
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/global')
-rw-r--r--src/corelib/global/qendian.h2
-rw-r--r--src/corelib/global/qglobal.cpp7
-rw-r--r--src/corelib/global/qglobal.h12
-rw-r--r--src/corelib/global/qnumeric_p.h6
4 files changed, 6 insertions, 21 deletions
diff --git a/src/corelib/global/qendian.h b/src/corelib/global/qendian.h
index e049fb6549..4048eca953 100644
--- a/src/corelib/global/qendian.h
+++ b/src/corelib/global/qendian.h
@@ -79,7 +79,7 @@ template <typename T> inline void qbswap(const T src, uchar *dest)
// If you want to avoid the memcopy, you must write specializations for this function
template <typename T> inline void qToUnaligned(const T src, uchar *dest)
{
- qMemCopy(dest, &src, sizeof(T));
+ memcpy(dest, &src, sizeof(T));
}
/* T qFromLittleEndian(const uchar *src)
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp
index 8125161897..51849d701a 100644
--- a/src/corelib/global/qglobal.cpp
+++ b/src/corelib/global/qglobal.cpp
@@ -1964,13 +1964,6 @@ Q_CORE_EXPORT unsigned int qt_int_sqrt(unsigned int n)
return p;
}
-#if defined(qMemCopy)
-# undef qMemCopy
-#endif
-#if defined(qMemSet)
-# undef qMemSet
-#endif
-
void *qMemCopy(void *dest, const void *src, size_t n) { return memcpy(dest, src, n); }
void *qMemSet(void *dest, int c, size_t n) { return memset(dest, c, n); }
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
index ec7de3b1c5..0648b08d1f 100644
--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -1189,12 +1189,12 @@ inline void qSwap(T &value1, T &value2)
Q_CORE_EXPORT QT_DEPRECATED void *qMalloc(size_t size) Q_ALLOC_SIZE(1);
Q_CORE_EXPORT QT_DEPRECATED void qFree(void *ptr);
Q_CORE_EXPORT QT_DEPRECATED void *qRealloc(void *ptr, size_t size) Q_ALLOC_SIZE(2);
+Q_CORE_EXPORT QT_DEPRECATED void *qMemCopy(void *dest, const void *src, size_t n);
+Q_CORE_EXPORT QT_DEPRECATED void *qMemSet(void *dest, int c, size_t n);
#endif
Q_CORE_EXPORT void *qMallocAligned(size_t size, size_t alignment) Q_ALLOC_SIZE(1);
Q_CORE_EXPORT void *qReallocAligned(void *ptr, size_t size, size_t oldsize, size_t alignment) Q_ALLOC_SIZE(2);
Q_CORE_EXPORT void qFreeAligned(void *ptr);
-Q_CORE_EXPORT void *qMemCopy(void *dest, const void *src, size_t n);
-Q_CORE_EXPORT void *qMemSet(void *dest, int c, size_t n);
/*
@@ -1388,14 +1388,6 @@ inline const QForeachContainer<T> *qForeachContainer(const QForeachContainerBase
# endif
#endif
-#if 0
-/* tell gcc to use its built-in methods for some common functions */
-#if defined(QT_NO_DEBUG) && defined(Q_CC_GNU)
-# define qMemCopy __builtin_memcpy
-# define qMemSet __builtin_memset
-#endif
-#endif
-
template <typename T> static inline T *qGetPtrHelper(T *ptr) { return ptr; }
template <typename Wrapper> static inline typename Wrapper::pointer qGetPtrHelper(const Wrapper &p) { return p.data(); }
diff --git a/src/corelib/global/qnumeric_p.h b/src/corelib/global/qnumeric_p.h
index 851c18203d..cc8e8d271a 100644
--- a/src/corelib/global/qnumeric_p.h
+++ b/src/corelib/global/qnumeric_p.h
@@ -100,7 +100,7 @@ static inline double qt_inf()
: qt_le_inf_bytes);
union { unsigned char c[8]; double d; } returnValue;
- qMemCopy(returnValue.c, bytes, sizeof(returnValue.c));
+ memcpy(returnValue.c, bytes, sizeof(returnValue.c));
return returnValue.d;
}
@@ -115,7 +115,7 @@ static inline double qt_snan()
: qt_le_snan_bytes);
union { unsigned char c[8]; double d; } returnValue;
- qMemCopy(returnValue.c, bytes, sizeof(returnValue.c));
+ memcpy(returnValue.c, bytes, sizeof(returnValue.c));
return returnValue.d;
}
@@ -130,7 +130,7 @@ static inline double qt_qnan()
: qt_le_qnan_bytes);
union { unsigned char c[8]; double d; } returnValue;
- qMemCopy(returnValue.c, bytes, sizeof(returnValue.c));
+ memcpy(returnValue.c, bytes, sizeof(returnValue.c));
return returnValue.d;
}