Use QString::DataPointer instead of QStringPrivate
Preparations to move QString over to use QArrayDataPointer instead of it's own private struct. Change-Id: I7796a595393394083f6a85863e3c710ebbdea149 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
20041afe3b
commit
f8d2975b6a
@ -82,7 +82,7 @@ QBinaryJsonValue::QBinaryJsonValue(QBinaryJsonPrivate::MutableData *data,
|
|||||||
QBinaryJsonValue::QBinaryJsonValue(QString string)
|
QBinaryJsonValue::QBinaryJsonValue(QString string)
|
||||||
: d(nullptr), t(QJsonValue::String)
|
: d(nullptr), t(QJsonValue::String)
|
||||||
{
|
{
|
||||||
stringData = *(QStringPrivate *)(&string);
|
stringData = string.data_ptr();
|
||||||
stringData.d->ref();
|
stringData.d->ref();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,7 +121,7 @@ private:
|
|||||||
quint64 ui;
|
quint64 ui;
|
||||||
bool b;
|
bool b;
|
||||||
double dbl;
|
double dbl;
|
||||||
QStringPrivate stringData;
|
QString::DataPointer stringData;
|
||||||
const QBinaryJsonPrivate::Base *base;
|
const QBinaryJsonPrivate::Base *base;
|
||||||
};
|
};
|
||||||
QBinaryJsonPrivate::MutableData *d = nullptr; // needed for Objects and Arrays
|
QBinaryJsonPrivate::MutableData *d = nullptr; // needed for Objects and Arrays
|
||||||
|
@ -4895,7 +4895,7 @@ QString QString::mid(int position, int n) const
|
|||||||
case QContainerImplHelper::Empty:
|
case QContainerImplHelper::Empty:
|
||||||
{
|
{
|
||||||
QPair<Data *, ushort *> pair = Data::allocate(0);
|
QPair<Data *, ushort *> pair = Data::allocate(0);
|
||||||
QStringPrivate empty = { pair.first, pair.second, 0 };
|
DataPointer empty = { pair.first, pair.second, 0 };
|
||||||
return QString(empty);
|
return QString(empty);
|
||||||
}
|
}
|
||||||
case QContainerImplHelper::Full:
|
case QContainerImplHelper::Full:
|
||||||
@ -5345,9 +5345,9 @@ QVector<uint> QtPrivate::convertToUcs4(QStringView string)
|
|||||||
return qt_convert_to_ucs4(string);
|
return qt_convert_to_ucs4(string);
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringPrivate QString::fromLatin1_helper(const char *str, int size)
|
QString::DataPointer QString::fromLatin1_helper(const char *str, int size)
|
||||||
{
|
{
|
||||||
QStringPrivate d;
|
DataPointer d;
|
||||||
if (!str) {
|
if (!str) {
|
||||||
d.d = Data::sharedNull();
|
d.d = Data::sharedNull();
|
||||||
d.b = Data::sharedNullData();
|
d.b = Data::sharedNullData();
|
||||||
@ -5373,7 +5373,7 @@ QStringPrivate QString::fromLatin1_helper(const char *str, int size)
|
|||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringPrivate QString::fromAscii_helper(const char *str, int size)
|
QString::DataPointer QString::fromAscii_helper(const char *str, int size)
|
||||||
{
|
{
|
||||||
QString s = fromUtf8(str, size);
|
QString s = fromUtf8(str, size);
|
||||||
s.d.d->ref();
|
s.d.d->ref();
|
||||||
@ -5423,7 +5423,7 @@ QString QString::fromLocal8Bit_helper(const char *str, int size)
|
|||||||
return QString();
|
return QString();
|
||||||
if (size == 0 || (!*str && size < 0)) {
|
if (size == 0 || (!*str && size < 0)) {
|
||||||
QPair<Data *, ushort *> pair = Data::allocate(0);
|
QPair<Data *, ushort *> pair = Data::allocate(0);
|
||||||
QStringPrivate empty = { pair.first, pair.second, 0 };
|
QString::DataPointer empty = { pair.first, pair.second, 0 };
|
||||||
return QString(empty);
|
return QString(empty);
|
||||||
}
|
}
|
||||||
#if QT_CONFIG(textcodec)
|
#if QT_CONFIG(textcodec)
|
||||||
@ -9098,7 +9098,7 @@ bool QString::isRightToLeft() const
|
|||||||
*/
|
*/
|
||||||
QString QString::fromRawData(const QChar *unicode, int size)
|
QString QString::fromRawData(const QChar *unicode, int size)
|
||||||
{
|
{
|
||||||
QStringPrivate x;
|
QString::DataPointer x;
|
||||||
x.size = size;
|
x.size = size;
|
||||||
if (!unicode) {
|
if (!unicode) {
|
||||||
x.d = Data::sharedNull();
|
x.d = Data::sharedNull();
|
||||||
|
@ -247,6 +247,8 @@ class Q_CORE_EXPORT QString
|
|||||||
{
|
{
|
||||||
typedef QTypedArrayData<ushort> Data;
|
typedef QTypedArrayData<ushort> Data;
|
||||||
public:
|
public:
|
||||||
|
typedef QStringPrivate DataPointer;
|
||||||
|
|
||||||
inline QString() noexcept;
|
inline QString() noexcept;
|
||||||
explicit QString(const QChar *unicode, int size = -1);
|
explicit QString(const QChar *unicode, int size = -1);
|
||||||
QString(QChar c);
|
QString(QChar c);
|
||||||
@ -916,7 +918,7 @@ public:
|
|||||||
bool isRightToLeft() const;
|
bool isRightToLeft() const;
|
||||||
|
|
||||||
QString(int size, Qt::Initialization);
|
QString(int size, Qt::Initialization);
|
||||||
explicit QString(QStringPrivate dd) : d(dd) {}
|
explicit QString(DataPointer dd) : d(dd) {}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
#if defined(QT_NO_CAST_FROM_ASCII)
|
#if defined(QT_NO_CAST_FROM_ASCII)
|
||||||
@ -928,7 +930,7 @@ private:
|
|||||||
QString &operator=(const QByteArray &a);
|
QString &operator=(const QByteArray &a);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
QStringPrivate d;
|
DataPointer d;
|
||||||
|
|
||||||
friend inline bool operator==(QChar, const QString &) noexcept;
|
friend inline bool operator==(QChar, const QString &) noexcept;
|
||||||
friend inline bool operator< (QChar, const QString &) noexcept;
|
friend inline bool operator< (QChar, const QString &) noexcept;
|
||||||
@ -966,8 +968,8 @@ private:
|
|||||||
static QString trimmed_helper(QString &str);
|
static QString trimmed_helper(QString &str);
|
||||||
static QString simplified_helper(const QString &str);
|
static QString simplified_helper(const QString &str);
|
||||||
static QString simplified_helper(QString &str);
|
static QString simplified_helper(QString &str);
|
||||||
static QStringPrivate fromLatin1_helper(const char *str, int size = -1);
|
static DataPointer fromLatin1_helper(const char *str, int size = -1);
|
||||||
static QStringPrivate fromAscii_helper(const char *str, int size = -1);
|
static DataPointer fromAscii_helper(const char *str, int size = -1);
|
||||||
static QString fromUtf8_helper(const char *str, int size);
|
static QString fromUtf8_helper(const char *str, int size);
|
||||||
static QString fromLocal8Bit_helper(const char *, int size);
|
static QString fromLocal8Bit_helper(const char *, int size);
|
||||||
static QByteArray toLatin1_helper(const QString &);
|
static QByteArray toLatin1_helper(const QString &);
|
||||||
@ -1002,8 +1004,7 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef QStringPrivate DataPtr;
|
inline DataPointer &data_ptr() { return d; }
|
||||||
inline DataPtr &data_ptr() { return d; }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -605,7 +605,7 @@ QString verifyZeroTermination(const QString &str)
|
|||||||
{
|
{
|
||||||
// This test does some evil stuff, it's all supposed to work.
|
// This test does some evil stuff, it's all supposed to work.
|
||||||
|
|
||||||
QString::DataPtr strDataPtr = const_cast<QString &>(str).data_ptr();
|
QString::DataPointer strDataPtr = const_cast<QString &>(str).data_ptr();
|
||||||
|
|
||||||
// Skip if isStatic() or fromRawData(), as those offer no guarantees
|
// Skip if isStatic() or fromRawData(), as those offer no guarantees
|
||||||
if (strDataPtr.d->isStatic() || !strDataPtr.d->isMutable())
|
if (strDataPtr.d->isStatic() || !strDataPtr.d->isMutable())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user