QResource: use QStringView
Saves 240B in QtCore text size on optimized GCC 7 Linux AMD64 builds. Change-Id: Ifa7b8735027575fbe381896dce608b80ec458ee9 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com> Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru>
This commit is contained in:
parent
8d44bb2c54
commit
58f9629a48
@ -66,10 +66,9 @@ QT_BEGIN_NAMESPACE
|
|||||||
class QStringSplitter
|
class QStringSplitter
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QStringSplitter(const QString &s)
|
explicit QStringSplitter(QStringView sv)
|
||||||
: m_string(s), m_data(m_string.constData()), m_len(s.length()), m_pos(0)
|
: m_data(sv.data()), m_len(sv.size())
|
||||||
{
|
{
|
||||||
m_splitChar = QLatin1Char('/');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool hasNext() {
|
inline bool hasNext() {
|
||||||
@ -78,18 +77,17 @@ public:
|
|||||||
return m_pos < m_len;
|
return m_pos < m_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline QStringRef next() {
|
inline QStringView next() {
|
||||||
int start = m_pos;
|
int start = m_pos;
|
||||||
while (m_pos < m_len && m_data[m_pos] != m_splitChar)
|
while (m_pos < m_len && m_data[m_pos] != m_splitChar)
|
||||||
++m_pos;
|
++m_pos;
|
||||||
return QStringRef(&m_string, start, m_pos - start);
|
return QStringView(m_data + start, m_pos - start);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString m_string;
|
|
||||||
const QChar *m_data;
|
const QChar *m_data;
|
||||||
QChar m_splitChar;
|
qssize_t m_len;
|
||||||
int m_len;
|
qssize_t m_pos = 0;
|
||||||
int m_pos;
|
QChar m_splitChar = QLatin1Char('/');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -678,7 +676,7 @@ int QResourceRoot::findNode(const QString &_path, const QLocale &locale) const
|
|||||||
|
|
||||||
QStringSplitter splitter(path);
|
QStringSplitter splitter(path);
|
||||||
while (child_count && splitter.hasNext()) {
|
while (child_count && splitter.hasNext()) {
|
||||||
QStringRef segment = splitter.next();
|
QStringView segment = splitter.next();
|
||||||
|
|
||||||
#ifdef DEBUG_RESOURCE_MATCH
|
#ifdef DEBUG_RESOURCE_MATCH
|
||||||
qDebug() << " CHILDREN" << segment;
|
qDebug() << " CHILDREN" << segment;
|
||||||
|
Loading…
Reference in New Issue
Block a user