summaryrefslogtreecommitdiffstats
path: root/qmake/library
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2020-04-03 11:49:27 +0200
committerLars Knoll <lars.knoll@qt.io>2020-05-05 18:41:10 +0200
commit52f3a7d9d40d3bf835bb0716ad201ee56731b980 (patch)
treea736d2cca2516f2ad2003ff28b34e7a8ff483cf6 /qmake/library
parentae7e701074be97130aa45f780e2456981850b432 (diff)
Build qmake with QT_USE_STRINGBUILDER
Should improve performance and is going to be required in the future anyway. Change-Id: I89d7c50441d2491da1ab0a4d564dcc91f52ade85 Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Diffstat (limited to 'qmake/library')
-rw-r--r--qmake/library/proitems.h74
1 files changed, 54 insertions, 20 deletions
diff --git a/qmake/library/proitems.h b/qmake/library/proitems.h
index 333f9ed889..09c5504fdf 100644
--- a/qmake/library/proitems.h
+++ b/qmake/library/proitems.h
@@ -70,9 +70,16 @@ public:
ProString();
ProString(const ProString &other);
ProString &operator=(const ProString &) = default;
- PROITEM_EXPLICIT ProString(const QString &str);
+ template<typename A, typename B>
+ ProString &operator=(const QStringBuilder<A, B> &str)
+ { return *this = QString(str); }
+ ProString(const QString &str);
PROITEM_EXPLICIT ProString(const QStringRef &str);
PROITEM_EXPLICIT ProString(const char *str);
+ template<typename A, typename B>
+ ProString(const QStringBuilder<A, B> &str)
+ : ProString(QString(str))
+ {}
ProString(const QString &str, int offset, int length);
void setValue(const QString &str);
void clear() { m_string.clear(); m_length = 0; }
@@ -83,12 +90,16 @@ public:
ProString &prepend(const ProString &other);
ProString &append(const ProString &other, bool *pending = nullptr);
ProString &append(const QString &other) { return append(ProString(other)); }
+ template<typename A, typename B>
+ ProString &append(const QStringBuilder<A, B> &other) { return append(QString(other)); }
ProString &append(const QLatin1String other);
ProString &append(const char *other) { return append(QLatin1String(other)); }
ProString &append(QChar other);
ProString &append(const ProStringList &other, bool *pending = nullptr, bool skipEmpty1st = false);
ProString &operator+=(const ProString &other) { return append(other); }
ProString &operator+=(const QString &other) { return append(other); }
+ template<typename A, typename B>
+ ProString &operator+=(const QStringBuilder<A, B> &other) { return append(QString(other)); }
ProString &operator+=(const QLatin1String other) { return append(other); }
ProString &operator+=(const char *other) { return append(other); }
ProString &operator+=(QChar other) { return append(other); }
@@ -123,9 +134,13 @@ public:
bool startsWith(const QString &sub, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return toQStringRef().startsWith(sub, cs); }
bool startsWith(const char *sub, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return toQStringRef().startsWith(QLatin1String(sub), cs); }
bool startsWith(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return toQStringRef().startsWith(c, cs); }
+ template<typename A, typename B>
+ bool startsWith(const QStringBuilder<A, B> &str) { return startsWith(QString(str)); }
bool endsWith(const ProString &sub, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return toQStringRef().endsWith(sub.toQStringRef(), cs); }
bool endsWith(const QString &sub, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return toQStringRef().endsWith(sub, cs); }
bool endsWith(const char *sub, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return toQStringRef().endsWith(QLatin1String(sub), cs); }
+ template<typename A, typename B>
+ bool endsWith(const QStringBuilder<A, B> &str) { return endsWith(QString(str)); }
bool endsWith(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return toQStringRef().endsWith(c, cs); }
int indexOf(const QString &s, int from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return toQStringRef().indexOf(s, from, cs); }
int indexOf(const char *s, int from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return toQStringRef().indexOf(QLatin1String(s), from, cs); }
@@ -179,10 +194,15 @@ private:
};
Q_DECLARE_TYPEINFO(ProString, Q_MOVABLE_TYPE);
+
class ProKey : public ProString {
public:
ALWAYS_INLINE ProKey() : ProString() {}
explicit ProKey(const QString &str);
+ template<typename A, typename B>
+ ProKey(const QStringBuilder<A, B> &str)
+ : ProString(str)
+ {}
PROITEM_EXPLICIT ProKey(const char *str);
ProKey(const QString &str, int off, int len);
ProKey(const QString &str, int off, int len, uint hash);
@@ -206,31 +226,43 @@ private:
};
Q_DECLARE_TYPEINFO(ProKey, Q_MOVABLE_TYPE);
+template <> struct QConcatenable<ProString> : private QAbstractConcatenable
+{
+ typedef ProString type;
+ typedef QString ConvertTo;
+ enum { ExactSize = true };
+ static int size(const ProString &a) { return a.length(); }
+ static inline void appendTo(const ProString &a, QChar *&out)
+ {
+ const auto n = a.size();
+ memcpy(out, a.toQStringView().data(), sizeof(QChar) * n);
+ out += n;
+ }
+};
+
+template <> struct QConcatenable<ProKey> : private QAbstractConcatenable
+{
+ typedef ProKey type;
+ typedef QString ConvertTo;
+ enum { ExactSize = true };
+ static int size(const ProKey &a) { return a.length(); }
+ static inline void appendTo(const ProKey &a, QChar *&out)
+ {
+ const auto n = a.size();
+ memcpy(out, a.toQStringView().data(), sizeof(QChar) * n);
+ out += n;
+ }
+};
+
+
size_t qHash(const ProString &str);
-QString operator+(const ProString &one, const ProString &two);
-inline QString operator+(const ProString &one, const QString &two)
- { return one.toQStringRef() + two; }
-inline QString operator+(const QString &one, const ProString &two)
- { return one + two.toQStringRef(); }
-
-inline QString operator+(const ProString &one, const char *two)
- { return one.toQStringRef() + QLatin1String(two); }
-inline QString operator+(const char *one, const ProString &two)
- { return QLatin1String(one) + two.toQStringRef(); }
-inline QString operator+(const ProString &one, QChar two)
- { return one.toQStringRef() + two; }
-inline QString operator+(QChar one, const ProString &two)
- { return one + two.toQStringRef(); }
inline QString &operator+=(QString &that, const ProString &other)
{ return that += other.toQStringRef(); }
-inline bool operator==(const QString &that, const ProString &other)
- { return other == that; }
-inline bool operator!=(const QString &that, const ProString &other)
- { return !(other == that); }
-
QTextStream &operator<<(QTextStream &t, const ProString &str);
+template<typename A, typename B>
+QTextStream &operator<<(QTextStream &t, const QStringBuilder<A, B> &str) { return t << QString(str); }
// This class manages read-only access to a ProString via a raw data QString
// temporary, ensuring that the latter is accessed exclusively.
@@ -296,6 +328,8 @@ public:
QString join(const ProString &sep) const;
QString join(const QString &sep) const;
QString join(QChar sep) const;
+ template<typename A, typename B>
+ QString join(const QStringBuilder<A, B> &str) { return join(QString(str)); }
void insertUnique(const ProStringList &value);