From 2532ddc48b802fd8d4f5f15e128c932df85f007e Mon Sep 17 00:00:00 2001 From: Harald Fernengel Date: Tue, 20 Dec 2011 13:42:17 +0100 Subject: make QString::fromLatin1 partially inline This allows us to benefit from compile time optimizations when calling strlen() Change-Id: If6694117e613a012fce97f8664e6b43005d255de Reviewed-by: Thiago Macieira --- src/corelib/tools/qstring.cpp | 6 +----- src/corelib/tools/qstring.h | 6 +++++- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index fb818e37b8..241a77d057 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -3818,7 +3818,7 @@ QString::Data *QString::fromAscii_helper(const char *str, int size) return fromLatin1_helper(str, size); } -/*! +/*! \fn QString QString::fromLatin1(const char *str, int size) Returns a QString initialized with the first \a size characters of the Latin-1 string \a str. @@ -3827,10 +3827,6 @@ QString::Data *QString::fromAscii_helper(const char *str, int size) \sa toLatin1(), fromAscii(), fromUtf8(), fromLocal8Bit() */ -QString QString::fromLatin1(const char *str, int size) -{ - return QString(fromLatin1_helper(str, size), 0); -} /*! diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h index 4e1e67bfa6..cccf275ffd 100644 --- a/src/corelib/tools/qstring.h +++ b/src/corelib/tools/qstring.h @@ -408,7 +408,11 @@ public: QVector toUcs4() const Q_REQUIRED_RESULT; static QString fromAscii(const char *, int size = -1); - static QString fromLatin1(const char *, int size = -1); + static inline QString fromLatin1(const char *str, int size = -1) + { + // make this inline so we can benefit from strlen() compile time optimization + return QString(fromLatin1_helper(str, (str && size == -1) ? int(strlen(str)) : size), 0); + } static QString fromUtf8(const char *, int size = -1); static QString fromLocal8Bit(const char *, int size = -1); static QString fromUtf16(const ushort *, int size = -1); -- cgit v1.2.3