summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qstring.cpp
diff options
context:
space:
mode:
authorHarald Fernengel <harald.fernengel@nokia.com>2011-12-21 12:03:08 +0100
committerQt by Nokia <qt-info@nokia.com>2011-12-22 13:20:40 +0100
commit500fd522324a891f4683723a0f69bfda968adb8e (patch)
tree74901718f01029c85105540fd54e575123f0957e /src/corelib/tools/qstring.cpp
parent40cfdf30fa6c68da8a5cbd37e21d844239545585 (diff)
Use strlen() inline whenever possible
This allows us to benefit from compile-time optimization Change-Id: I63dfde3758fcb0ff919fdc0418df1b7586da0b2f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/tools/qstring.cpp')
-rw-r--r--src/corelib/tools/qstring.cpp25
1 files changed, 10 insertions, 15 deletions
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp
index 241a77d057..be8876af48 100644
--- a/src/corelib/tools/qstring.cpp
+++ b/src/corelib/tools/qstring.cpp
@@ -3822,25 +3822,25 @@ QString::Data *QString::fromAscii_helper(const char *str, int size)
Returns a QString initialized with the first \a size characters
of the Latin-1 string \a str.
- If \a size is -1 (default), it is taken to be qstrlen(\a
+ If \a size is -1 (default), it is taken to be strlen(\a
str).
\sa toLatin1(), fromAscii(), fromUtf8(), fromLocal8Bit()
*/
-/*!
+/*! \fn QString QString::fromLocal8Bit(const char *str, int size)
Returns a QString initialized with the first \a size characters
of the 8-bit string \a str.
- If \a size is -1 (default), it is taken to be qstrlen(\a
+ If \a size is -1 (default), it is taken to be strlen(\a
str).
QTextCodec::codecForLocale() is used to perform the conversion.
\sa toLocal8Bit(), fromAscii(), fromLatin1(), fromUtf8()
*/
-QString QString::fromLocal8Bit(const char *str, int size)
+QString QString::fromLocal8Bit_helper(const char *str, int size)
{
if (!str)
return QString();
@@ -3856,11 +3856,11 @@ QString QString::fromLocal8Bit(const char *str, int size)
return fromLatin1(str, size);
}
-/*!
+/*! \fn QString QString::fromAscii(const char *, int size);
Returns a QString initialized with the first \a size characters
from the string \a str.
- If \a size is -1 (default), it is taken to be qstrlen(\a
+ If \a size is -1 (default), it is taken to be strlen(\a
str).
Note that, despite the name, this function actually uses the codec
@@ -3871,16 +3871,12 @@ QString QString::fromLocal8Bit(const char *str, int size)
\sa toAscii(), fromLatin1(), fromUtf8(), fromLocal8Bit()
*/
-QString QString::fromAscii(const char *str, int size)
-{
- return QString(fromAscii_helper(str, size), 0);
-}
-/*!
+/*! \fn QString QString::fromUtf8(const char *str, int size)
Returns a QString initialized with the first \a size bytes
of the UTF-8 string \a str.
- If \a size is -1 (default), it is taken to be qstrlen(\a
+ If \a size is -1 (default), it is taken to be strlen(\a
str).
UTF-8 is a Unicode codec and can represent all characters in a Unicode
@@ -3897,13 +3893,12 @@ QString QString::fromAscii(const char *str, int size)
\sa toUtf8(), fromAscii(), fromLatin1(), fromLocal8Bit()
*/
-QString QString::fromUtf8(const char *str, int size)
+QString QString::fromUtf8_helper(const char *str, int size)
{
if (!str)
return QString();
- if (size < 0)
- size = qstrlen(str);
+ Q_ASSERT(size != -1);
return QUtf8::convertToUnicode(str, size, 0);
}