diff options
| author | Anton Kudryavtsev <anton.kudryavtsev@vk.team> | 2023-09-13 15:46:18 +0300 |
|---|---|---|
| committer | Anton Kudryavtsev <anton.kudryavtsev@vk.team> | 2023-09-15 13:04:18 +0300 |
| commit | df66aa688c471980ab664401ecf387ada9b61e3d (patch) | |
| tree | 964f14c0bba227ca20d90a2ac8cc1b726d049727 /src | |
| parent | cc2de22ec2f90bc47f97ab4f9190c37942f6302c (diff) | |
qml: replace fromLatin with _L1
to improve readability and reduce allocations
Change-Id: I1ffe10d6a14fb9cc09dd438cca84f4a1d74b8cb8
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src')
| -rw-r--r-- | src/qml/jsapi/qjsengine.cpp | 2 | ||||
| -rw-r--r-- | src/qml/jsruntime/qv4object.cpp | 9 | ||||
| -rw-r--r-- | src/qml/jsruntime/qv4setobject.cpp | 3 | ||||
| -rw-r--r-- | src/qml/jsruntime/qv4stringobject.cpp | 5 | ||||
| -rw-r--r-- | src/qml/qml/qqmlpropertyvalidator.cpp | 2 |
5 files changed, 12 insertions, 9 deletions
diff --git a/src/qml/jsapi/qjsengine.cpp b/src/qml/jsapi/qjsengine.cpp index 29ca243649..6aeeacbb02 100644 --- a/src/qml/jsapi/qjsengine.cpp +++ b/src/qml/jsapi/qjsengine.cpp @@ -533,7 +533,7 @@ QJSValue QJSEngine::evaluate(const QString& program, const QString& fileName, in result = v4->catchException(&trace); if (exceptionStackTrace) { for (auto &&frame: trace) - exceptionStackTrace->push_back(QString::fromLatin1("%1:%2:%3:%4").arg( + exceptionStackTrace->push_back(QLatin1StringView("%1:%2:%3:%4").arg( frame.function, QString::number(qAbs(frame.line)), QString::number(frame.column), diff --git a/src/qml/jsruntime/qv4object.cpp b/src/qml/jsruntime/qv4object.cpp index 19058195bc..f96b8f724b 100644 --- a/src/qml/jsruntime/qv4object.cpp +++ b/src/qml/jsruntime/qv4object.cpp @@ -20,6 +20,7 @@ #include <stdint.h> using namespace QV4; +using namespace Qt::Literals::StringLiterals; Q_LOGGING_CATEGORY(lcJavaScriptGlobals, "qt.qml.js.globals") @@ -179,16 +180,16 @@ void Object::defineAccessorProperty(StringOrSymbol *name, VTable::Call getter, V QV4::Scope scope(v4); ScopedProperty p(scope); QString n = name->toQString(); - if (!n.isEmpty() && n.at(0) == QLatin1Char('@')) - n = QChar::fromLatin1('[') + QStringView{n}.mid(1) + QChar::fromLatin1(']'); + if (!n.isEmpty() && n.at(0) == '@'_L1) + n = '['_L1 + QStringView{n}.mid(1) + ']'_L1; if (getter) { - ScopedString getName(scope, v4->newString(QString::fromLatin1("get ") + n)); + ScopedString getName(scope, v4->newString("get "_L1 + n)); p->setGetter(ScopedFunctionObject(scope, FunctionObject::createBuiltinFunction(v4, getName, getter, 0))); } else { p->setGetter(nullptr); } if (setter) { - ScopedString setName(scope, v4->newString(QString::fromLatin1("set ") + n)); + ScopedString setName(scope, v4->newString("set "_L1 + n)); p->setSetter(ScopedFunctionObject(scope, FunctionObject::createBuiltinFunction(v4, setName, setter, 0))); } else { p->setSetter(nullptr); diff --git a/src/qml/jsruntime/qv4setobject.cpp b/src/qml/jsruntime/qv4setobject.cpp index 01fc62a4d4..a7589a40db 100644 --- a/src/qml/jsruntime/qv4setobject.cpp +++ b/src/qml/jsruntime/qv4setobject.cpp @@ -8,6 +8,7 @@ #include "qv4symbol_p.h" using namespace QV4; +using namespace Qt::Literals::StringLiterals; DEFINE_OBJECT_VTABLE(SetCtor); DEFINE_OBJECT_VTABLE(WeakSetCtor); @@ -37,7 +38,7 @@ ReturnedValue WeakSetCtor::construct(const FunctionObject *f, const Value *argv, if (argc > 0) { ScopedValue iterable(scope, argv[0]); if (!iterable->isUndefined() && !iterable->isNull()) { - ScopedFunctionObject adder(scope, a->get(ScopedString(scope, scope.engine->newString(QString::fromLatin1("add"))))); + ScopedFunctionObject adder(scope, a->get(ScopedString(scope, scope.engine->newString(u"add"_s)))); if (!adder) return scope.engine->throwTypeError(); ScopedObject iter(scope, Runtime::GetIterator::call(scope.engine, iterable, true)); diff --git a/src/qml/jsruntime/qv4stringobject.cpp b/src/qml/jsruntime/qv4stringobject.cpp index 98bb6347d3..ad3c39c7b9 100644 --- a/src/qml/jsruntime/qv4stringobject.cpp +++ b/src/qml/jsruntime/qv4stringobject.cpp @@ -30,6 +30,7 @@ #endif using namespace QV4; +using namespace Qt::Literals::StringLiterals; DEFINE_OBJECT_VTABLE(StringObject); @@ -599,7 +600,7 @@ ReturnedValue StringPrototype::method_padEnd(const FunctionObject *f, const Valu double maxLen = argv[0].toInteger(); if (maxLen <= s->d()->length()) return s->asReturnedValue(); - QString fillString = (argc > 1 && !argv[1].isUndefined()) ? argv[1].toQString() : QString::fromLatin1(" "); + QString fillString = (argc > 1 && !argv[1].isUndefined()) ? argv[1].toQString() : u" "_s; if (v4->hasException) return Encode::undefined(); @@ -638,7 +639,7 @@ ReturnedValue StringPrototype::method_padStart(const FunctionObject *f, const Va double maxLen = argv[0].toInteger(); if (maxLen <= s->d()->length()) return s->asReturnedValue(); - QString fillString = (argc > 1 && !argv[1].isUndefined()) ? argv[1].toQString() : QString::fromLatin1(" "); + QString fillString = (argc > 1 && !argv[1].isUndefined()) ? argv[1].toQString() : u" "_s; if (v4->hasException) return Encode::undefined(); diff --git a/src/qml/qml/qqmlpropertyvalidator.cpp b/src/qml/qml/qqmlpropertyvalidator.cpp index 23f7516ee4..f4f2c0d433 100644 --- a/src/qml/qml/qqmlpropertyvalidator.cpp +++ b/src/qml/qml/qqmlpropertyvalidator.cpp @@ -610,7 +610,7 @@ QQmlError QQmlPropertyValidator::validateLiteralBinding( break; } - return warnOrError(tr("Invalid property assignment: unsupported type \"%1\"").arg(QString::fromLatin1(property->propType().name()))); + return warnOrError(tr("Invalid property assignment: unsupported type \"%1\"").arg(QLatin1StringView(property->propType().name()))); } break; } |
