diff options
Diffstat (limited to 'qmake/library/proitems.cpp')
-rw-r--r-- | qmake/library/proitems.cpp | 76 |
1 files changed, 17 insertions, 59 deletions
diff --git a/qmake/library/proitems.cpp b/qmake/library/proitems.cpp index e1cfbad8a1..2edd40a35c 100644 --- a/qmake/library/proitems.cpp +++ b/qmake/library/proitems.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the qmake application of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "proitems.h" @@ -32,6 +7,7 @@ #include <qset.h> #include <qstringlist.h> #include <qtextstream.h> +#include <private/qduplicatetracker_p.h> QT_BEGIN_NAMESPACE @@ -64,13 +40,13 @@ ProString::ProString(const ProString &other, OmitPreHashing) : } ProString::ProString(const QString &str, DoPreHashing) : - m_string(str), m_offset(0), m_length(str.length()), m_file(0) + m_string(str), m_offset(0), m_length(str.size()), m_file(0) { updatedHash(); } ProString::ProString(const QString &str) : - m_string(str), m_offset(0), m_length(str.length()), m_file(0), m_hash(0x80000000) + m_string(str), m_offset(0), m_length(str.size()), m_file(0), m_hash(0x80000000) { } @@ -108,7 +84,7 @@ ProString::ProString(const QString &str, int offset, int length) : void ProString::setValue(const QString &str) { - m_string = str, m_offset = 0, m_length = str.length(), m_hash = 0x80000000; + m_string = str, m_offset = 0, m_length = str.size(), m_hash = 0x80000000; } size_t ProString::updatedHash() const @@ -145,7 +121,7 @@ ProKey::ProKey(const QString &str, int off, int len, uint hash) : void ProKey::setValue(const QString &str) { - m_string = str, m_offset = 0, m_length = str.length(); + m_string = str, m_offset = 0, m_length = str.size(); updatedHash(); } @@ -168,7 +144,7 @@ ProString &ProString::prepend(const ProString &other) } else { m_string = other.toQStringView() + toQStringView(); m_offset = 0; - m_length = m_string.length(); + m_length = m_string.size(); if (!m_file) m_file = other.m_file; m_hash = 0x80000000; @@ -180,10 +156,10 @@ ProString &ProString::prepend(const ProString &other) ProString &ProString::append(const QLatin1String other) { if (other.size()) { - if (m_length != m_string.length()) { + if (m_length != m_string.size()) { m_string = toQStringView() + other; m_offset = 0; - m_length = m_string.length(); + m_length = m_string.size(); } else { Q_ASSERT(m_offset == 0); m_string.append(other); @@ -196,10 +172,10 @@ ProString &ProString::append(const QLatin1String other) ProString &ProString::append(QChar other) { - if (m_length != m_string.length()) { + if (m_length != m_string.size()) { m_string = toQStringView() + other; m_offset = 0; - m_length = m_string.length(); + m_length = m_string.size(); } else { Q_ASSERT(m_offset == 0); m_string.append(other); @@ -216,14 +192,14 @@ ProString &ProString::append(const ProString &other, bool *pending) if (!m_length) { *this = other; } else { - if (m_length != m_string.length()) + if (m_length != m_string.size()) m_string = toQString(); if (pending && !*pending) { m_string += QLatin1Char(' ') + other.toQStringView(); } else { m_string += other.toQStringView(); } - m_length = m_string.length(); + m_length = m_string.size(); m_offset = 0; if (other.m_file) m_file = other.m_file; @@ -247,14 +223,9 @@ ProString &ProString::append(const ProStringList &other, bool *pending, bool ski if (!m_length && sz == startIdx + 1) { *this = other.at(startIdx); } else { - int totalLength = sz - startIdx; - for (int i = startIdx; i < sz; ++i) - totalLength += other.at(i).size(); bool putSpace = false; if (pending && !*pending && m_length) putSpace = true; - else - totalLength--; m_string = toQString(); m_offset = 0; @@ -266,7 +237,7 @@ ProString &ProString::append(const ProStringList &other, bool *pending, bool ski const ProString &str = other.at(i); m_string += str.toQStringView(); } - m_length = m_string.length(); + m_length = m_string.size(); if (other.last().m_file) m_file = other.last().m_file; m_hash = 0x80000000; @@ -403,21 +374,8 @@ void ProStringList::removeEmpty() void ProStringList::removeDuplicates() { - int n = size(); - int j = 0; - QSet<ProString> seen; - seen.reserve(n); - for (int i = 0; i < n; ++i) { - const ProString &s = at(i); - if (seen.contains(s)) - continue; - seen.insert(s); - if (j != i) - (*this)[j] = s; - ++j; - } - if (n != j) - erase(begin() + j, end()); + QDuplicateTracker<ProString> seen(size()); + removeIf([&](const ProString &s) { return seen.hasSeen(s); }); } void ProStringList::insertUnique(const ProStringList &value) |