aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2021-10-27 13:27:06 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-10-30 21:28:02 +0000
commit2e57fa90777a9198f2777d662ec5e3bc15b1d625 (patch)
treeb002feb47488dba9afc5358a2e84a6c67e5d36ac
parent15e19fd0794a5527d4b94c821a4210849ed59f30 (diff)
shiboken6: Rewrite some helpers in terms of QStringView
This is a prerequisite for refactoring functions qualifying argument default values, allowing them to operate on substrings. Task-number: PYSIDE-1691 Change-Id: I5b368fdfe162ecc1a69a3958ed21d3563a05e1b0 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> (cherry picked from commit 9548ddd822b839ed0dfea27b26c74ad1c87746fd) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--sources/shiboken6/ApiExtractor/abstractmetafield.cpp2
-rw-r--r--sources/shiboken6/ApiExtractor/abstractmetafield.h2
-rw-r--r--sources/shiboken6/ApiExtractor/abstractmetalang.cpp2
-rw-r--r--sources/shiboken6/ApiExtractor/abstractmetalang.h2
-rw-r--r--sources/shiboken6/ApiExtractor/tests/testtemplates.cpp4
5 files changed, 6 insertions, 6 deletions
diff --git a/sources/shiboken6/ApiExtractor/abstractmetafield.cpp b/sources/shiboken6/ApiExtractor/abstractmetafield.cpp
index 45ea5601a..35306d5a0 100644
--- a/sources/shiboken6/ApiExtractor/abstractmetafield.cpp
+++ b/sources/shiboken6/ApiExtractor/abstractmetafield.cpp
@@ -64,7 +64,7 @@ AbstractMetaField::~AbstractMetaField() = default;
std::optional<AbstractMetaField>
AbstractMetaField::find(const AbstractMetaFieldList &haystack,
- const QString &needle)
+ QStringView needle)
{
for (const auto &f : haystack) {
if (f.name() == needle)
diff --git a/sources/shiboken6/ApiExtractor/abstractmetafield.h b/sources/shiboken6/ApiExtractor/abstractmetafield.h
index 794cce462..e36f4c30e 100644
--- a/sources/shiboken6/ApiExtractor/abstractmetafield.h
+++ b/sources/shiboken6/ApiExtractor/abstractmetafield.h
@@ -95,7 +95,7 @@ public:
TypeSystem::SnakeCase snakeCase() const;
static std::optional<AbstractMetaField>
- find(const AbstractMetaFieldList &haystack, const QString &needle);
+ find(const AbstractMetaFieldList &haystack, QStringView needle);
#ifndef QT_NO_DEBUG_STREAM
void formatDebug(QDebug &d) const;
diff --git a/sources/shiboken6/ApiExtractor/abstractmetalang.cpp b/sources/shiboken6/ApiExtractor/abstractmetalang.cpp
index 3e42f40ac..2e824fff7 100644
--- a/sources/shiboken6/ApiExtractor/abstractmetalang.cpp
+++ b/sources/shiboken6/ApiExtractor/abstractmetalang.cpp
@@ -1230,7 +1230,7 @@ AbstractMetaFunctionCList AbstractMetaClass::cppSignalFunctions() const
}
std::optional<AbstractMetaField>
- AbstractMetaClass::findField(const QString &name) const
+ AbstractMetaClass::findField(QStringView name) const
{
return AbstractMetaField::find(d->m_fields, name);
}
diff --git a/sources/shiboken6/ApiExtractor/abstractmetalang.h b/sources/shiboken6/ApiExtractor/abstractmetalang.h
index cc7fd7cec..555b7158f 100644
--- a/sources/shiboken6/ApiExtractor/abstractmetalang.h
+++ b/sources/shiboken6/ApiExtractor/abstractmetalang.h
@@ -182,7 +182,7 @@ public:
void addField(const AbstractMetaField &field);
bool hasStaticFields() const;
- std::optional<AbstractMetaField> findField(const QString &name) const;
+ std::optional<AbstractMetaField> findField(QStringView name) const;
const AbstractMetaEnumList &enums() const;
AbstractMetaEnumList &enums();
diff --git a/sources/shiboken6/ApiExtractor/tests/testtemplates.cpp b/sources/shiboken6/ApiExtractor/tests/testtemplates.cpp
index aa1d0414c..53cefaa49 100644
--- a/sources/shiboken6/ApiExtractor/tests/testtemplates.cpp
+++ b/sources/shiboken6/ApiExtractor/tests/testtemplates.cpp
@@ -584,13 +584,13 @@ void TestTemplates::testTemplateTypeDefs()
QCOMPARE(xmlValueMethod->type().cppSignature(), QLatin1String("int"));
// Check whether the m_value field is of type 'int'
- const auto valueField = optionalInt->findField(QLatin1String("m_value"));
+ const auto valueField = optionalInt->findField(u"m_value");
QVERIFY(valueField.has_value());
QCOMPARE(valueField->type().cppSignature(), QLatin1String("int"));
// ditto for typesystem XML
const auto xmlValueField =
- xmlOptionalInt->findField(QLatin1String("m_value"));
+ xmlOptionalInt->findField(u"m_value");
QVERIFY(xmlValueField.has_value());
QCOMPARE(xmlValueField->type().cppSignature(), QLatin1String("int"));
}