Commit bb0a8563 authored by Igor Kushnir's avatar Igor Kushnir
Browse files

Pass char16_t* instead of char* to [Qualified]Identifier()

Since https://commits.kde.org/kdevelop/1d9717164cc1eaf6919090ea21053864fce44b2f
these constructors take a QStringView. Passing an ordinary const char[]
string literal created a temporary QString, which entailed memory
allocation and deallocation. Passing a UTF-16 const char16_t[] string
literal creates a QStringView that simply references the string
literal's static storage, which is much more efficient.
parent 36506f4a
Pipeline #248338 passed with stage
in 2 minutes and 8 seconds
......@@ -1558,7 +1558,7 @@ QList<CompletionTreeItemPointer> CodeCompletionContext::completionItems(bool& ab
if ( ClassDeclaration* classDec = dynamic_cast<ClassDeclaration*>(decl) ) {
// search for ctor
decl = nullptr;
foreach ( Declaration* dec, classDec->internalContext()->findDeclarations(Identifier("__construct")) ) {
foreach ( Declaration* dec, classDec->internalContext()->findDeclarations(Identifier(u"__construct")) ) {
if ( dec->isFunctionDeclaration() ) {
decl = dec;
break;
......
......@@ -181,7 +181,7 @@ void ExpressionVisitor::visitVarExpression(VarExpressionAst *node)
{
DefaultVisitor::visitVarExpression(node);
if (node->isGenerator != -1) {
DeclarationPointer generatorDecl = findDeclarationImport(ClassDeclarationType, QualifiedIdentifier("generator"));
DeclarationPointer generatorDecl = findDeclarationImport(ClassDeclarationType, QualifiedIdentifier(u"generator"));
if (generatorDecl) {
m_result.setType(AbstractType::Ptr(new IntegralType(IntegralType::TypeMixed)));
......
......@@ -458,7 +458,7 @@ AbstractType::Ptr determineTypehint(const T* genericType, EditorIntegrator *edit
} else if (typehint.compare(QLatin1String("object"), Qt::CaseInsensitive) == 0) {
type = AbstractType::Ptr(new IntegralTypeExtended(IntegralTypeExtended::TypeObject));
} else if (typehint.compare(QLatin1String("iterable"), Qt::CaseInsensitive) == 0) {
DeclarationPointer traversableDecl = findDeclarationImportHelper(currentContext, QualifiedIdentifier("traversable"), ClassDeclarationType);
DeclarationPointer traversableDecl = findDeclarationImportHelper(currentContext, QualifiedIdentifier(u"traversable"), ClassDeclarationType);
if (traversableDecl) {
UnsureType::Ptr unsure(new UnsureType());
......
This diff is collapsed.
......@@ -227,7 +227,7 @@ void TestDUChainMultipleFiles::testUpdateForeach()
{
DUChainWriteLocker lock;
QVERIFY(f.topContext()->problems().isEmpty());
QCOMPARE(f.topContext()->findDeclarations(Identifier("k")).count(), 1);
QCOMPARE(f.topContext()->findDeclarations(Identifier(u"k")).count(), 1);
Declaration* kDec = f.topContext()->findDeclarations(Identifier(QStringLiteral("k"))).first();
QCOMPARE(kDec->rangeInCurrentRevision().start().line(), 1);
QCOMPARE(kDec->rangeInCurrentRevision().start().column(), 0);
......@@ -245,7 +245,7 @@ void TestDUChainMultipleFiles::testUpdateForeach()
{
DUChainWriteLocker lock;
QVERIFY(f.topContext()->problems().isEmpty());
QCOMPARE(f.topContext()->findDeclarations(Identifier("k")).count(), 1);
QCOMPARE(f.topContext()->findDeclarations(Identifier(u"k")).count(), 1);
Declaration* kDec = f.topContext()->findDeclarations(Identifier(QStringLiteral("k"))).first();
QCOMPARE(kDec->rangeInCurrentRevision().start().line(), 1);
QCOMPARE(kDec->rangeInCurrentRevision().start().column(), 25);
......@@ -297,7 +297,7 @@ void TestDUChainMultipleFiles::testIteratorForeachReparse() {
auto top = file.topContext();
QVERIFY(top);
QVERIFY(top->localDeclarations().size() == 2);
QCOMPARE(top->localDeclarations().at(0)->qualifiedIdentifier(), QualifiedIdentifier("a"));
QCOMPARE(top->localDeclarations().at(0)->qualifiedIdentifier(), QualifiedIdentifier(u"a"));
IntegralType::Ptr type = top->localDeclarations().at(0)->type<IntegralType>();
QVERIFY(type);
......
......@@ -44,7 +44,7 @@ void TestExpressionParser::newClass()
ExpressionParser p(true);
ExpressionEvaluationResult res = p.evaluateType(QByteArray("$i"), DUContextPointer(top), CursorInRevision(1, 0));
QVERIFY(res.type());
QCOMPARE(StructureType::Ptr::staticCast(res.type())->qualifiedIdentifier(), QualifiedIdentifier("a"));
QCOMPARE(StructureType::Ptr::staticCast(res.type())->qualifiedIdentifier(), QualifiedIdentifier(u"a"));
}
void TestExpressionParser::newSelf()
......@@ -62,7 +62,7 @@ void TestExpressionParser::newSelf()
DUContextPointer(top->childContexts().first()->childContexts().last()),
CursorInRevision(0, 30));
QVERIFY(res.type());
QCOMPARE(StructureType::Ptr::staticCast(res.type())->qualifiedIdentifier(), QualifiedIdentifier("a"));
QCOMPARE(StructureType::Ptr::staticCast(res.type())->qualifiedIdentifier(), QualifiedIdentifier(u"a"));
}
void TestExpressionParser::newStatic()
......@@ -80,7 +80,7 @@ void TestExpressionParser::newStatic()
DUContextPointer(top->childContexts().first()->childContexts().last()),
CursorInRevision(0, 30));
QVERIFY(res.type().cast<StructureType>());
QCOMPARE(res.type().cast<StructureType>()->qualifiedIdentifier(), QualifiedIdentifier("a"));
QCOMPARE(res.type().cast<StructureType>()->qualifiedIdentifier(), QualifiedIdentifier(u"a"));
}
void TestExpressionParser::memberVariable()
......@@ -98,7 +98,7 @@ void TestExpressionParser::memberVariable()
QVERIFY(res.type());
QCOMPARE(res.allDeclarations().count(), 1);
QCOMPARE(res.allDeclarations().first().data(), top->childContexts().first()->localDeclarations().first());
QCOMPARE(StructureType::Ptr::staticCast(res.type())->qualifiedIdentifier(), QualifiedIdentifier("a"));
QCOMPARE(StructureType::Ptr::staticCast(res.type())->qualifiedIdentifier(), QualifiedIdentifier(u"a"));
}
void TestExpressionParser::memberFunction()
{
......@@ -373,7 +373,7 @@ void TestExpressionParser::cast()
res = p.evaluateType(QByteArray("(object)$foo"), DUContextPointer(top), CursorInRevision(1, 0));
QVERIFY(StructureType::Ptr::dynamicCast(res.type()));
QVERIFY(StructureType::Ptr::staticCast(res.type())->qualifiedIdentifier() == QualifiedIdentifier("stdclass"));
QVERIFY(StructureType::Ptr::staticCast(res.type())->qualifiedIdentifier() == QualifiedIdentifier(u"stdclass"));
}
void TestExpressionParser::operations()
......
This diff is collapsed.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment