summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2017-04-10 10:17:34 +0200
committerMarc Mutz <marc.mutz@kdab.com>2017-04-20 17:02:44 +0000
commit7d4bf142d7a313fcec210edf7fee2850d886421d (patch)
treea00f733a663094ccbb6aa924cf897d1d8b7ccc86 /src/plugins
parentaf211b3993a3c3b98ad4feefcbf7861e0adab835 (diff)
QUuid: add fromString(QStringView/QLatin1String)
As for the formatting code, de-duplicate the parsing code by only parsing char*s, converting QChars to Latin-1 first in a small buffer. The QUuid(const char*) ctor performed no length checking, relying instead on the checks performed within _q_uuidFromHex(), which includes an implicit check for premature end (because NUL is not a valid token for the parser). The (QString) and (QByteArray) ctors did perform length checking. To the extent possible, this is removed, since it is handled by _q_uuidFromHex(). Failure cases need not be optimized. Only the QLatin1String overload needs to do some checking, because views in general are not NUL-terminated. The QStringView overload can just append a NUL when it converts to Latin-1. The only check I added to _q_uuidFromHex() is that for src == nullptr. It would otherwise be duplicated in several callers. While touching the internal functions, port to passing and returning by value. Saves 1.6KiB in text size on optimized GCC 6.1 Linux AMD64 builds, even though we added new API. Port some users to the new functions. Expand fromString() test. [ChangeLog][QtCore][QUuid] Added fromString(QStringView/QLatin1String). Change-Id: I519339419129550c86e0ea80514865cd6a768f5d Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/platforms/windows/qwindowsdialoghelpers.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp
index 0c4f27def2..8a00ed0e40 100644
--- a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp
+++ b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp
@@ -909,7 +909,7 @@ IShellItem *QWindowsNativeFileDialogBase::shellItem(const QUrl &url)
// (see https://msdn.microsoft.com/en-us/library/windows/desktop/dd378457(v=vs.85).aspx)
// specified as "clsid:<GUID>" (without '{', '}').
IShellItem *result = Q_NULLPTR;
- const QUuid uuid(url.path());
+ const auto uuid = QUuid::fromString(url.path());
if (uuid.isNull()) {
qWarning() << __FUNCTION__ << ": Invalid CLSID: " << url.path();
return Q_NULLPTR;