diff options
author | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2017-01-18 17:11:15 +0000 |
---|---|---|
committer | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2017-01-19 14:09:47 +0000 |
commit | a6cdfacf8d9c646333e81693e73e2c74173ad29a (patch) | |
tree | 5d02c92e55165001d65aa3dcad3dc8f18f4f2119 /src/network/kernel/qhostaddress.h | |
parent | f46496602e855dccccb6052de0f7ccbc74db40cd (diff) |
QHostAddress: make it implictly shared
QHostAddress is one of the few classes in Qt which is pimpl'd but not
implictly shared, making it suprisingly expensive to copy around, return
by value and so on. Being pimpl'd it is also still lacking a move
constructor, like most of such types in Qt.
Remove a bit of the surprise factor and make it implictly shared. In
practice this means making it eagerly parse host addresses from strings.
Since it was entirely implemented out of line, replacing it with a
implictly shared implementation is binary compatible.
[ChangeLog][QtNetwork][QHostAddress] QHostAddress is now implicitly
shared.
Change-Id: Ia7ff94efcb74e7321b7607cd690c5c162f685605
Reviewed-by: Richard J. Moore <rich@kde.org>
Diffstat (limited to 'src/network/kernel/qhostaddress.h')
-rw-r--r-- | src/network/kernel/qhostaddress.h | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/network/kernel/qhostaddress.h b/src/network/kernel/qhostaddress.h index 10fe33f6fa..3898fb02a8 100644 --- a/src/network/kernel/qhostaddress.h +++ b/src/network/kernel/qhostaddress.h @@ -44,7 +44,7 @@ #include <QtNetwork/qtnetworkglobal.h> #include <QtCore/qpair.h> #include <QtCore/qstring.h> -#include <QtCore/qscopedpointer.h> +#include <QtCore/qshareddata.h> #include <QtNetwork/qabstractsocket.h> struct sockaddr; @@ -66,7 +66,7 @@ typedef QIPv6Address Q_IPV6ADDR; class QHostAddress; // qHash is a friend, but we can't use default arguments for friends (ยง8.3.6.4) -Q_NETWORK_EXPORT uint qHash(const QHostAddress &key, uint seed = 0); +Q_NETWORK_EXPORT uint qHash(const QHostAddress &key, uint seed = 0) Q_DECL_NOTHROW; class Q_NETWORK_EXPORT QHostAddress { @@ -152,9 +152,9 @@ public: static QPair<QHostAddress, int> parseSubnet(const QString &subnet); - friend Q_NETWORK_EXPORT uint qHash(const QHostAddress &key, uint seed); + friend Q_NETWORK_EXPORT uint qHash(const QHostAddress &key, uint seed) Q_DECL_NOTHROW; protected: - QScopedPointer<QHostAddressPrivate> d; + QExplicitlySharedDataPointer<QHostAddressPrivate> d; }; Q_DECLARE_OPERATORS_FOR_FLAGS(QHostAddress::ConversionMode) Q_DECLARE_SHARED_NOT_MOVABLE_UNTIL_QT6(QHostAddress) |