QString::arg usage optimization

This commit is contained in:
Ilya Fedin 2023-12-22 03:50:42 +04:00 committed by John Preston
parent e6b9a07163
commit 29646707a1
7 changed files with 14 additions and 16 deletions

View file

@ -1092,7 +1092,7 @@ QString TryConvertUrlToLocal(QString url) {
const auto base = u"tg://privatepost?channel="_q + channel; const auto base = u"tg://privatepost?channel="_q + channel;
auto added = QString(); auto added = QString();
if (const auto threadPostMatch = regex_match(u"^/(\\d+)/(\\d+)(/?\\?|/?$)"_q, privateMatch->captured(2))) { if (const auto threadPostMatch = regex_match(u"^/(\\d+)/(\\d+)(/?\\?|/?$)"_q, privateMatch->captured(2))) {
added = u"&topic=%1&post=%2"_q.arg(threadPostMatch->captured(1)).arg(threadPostMatch->captured(2)); added = u"&topic=%1&post=%2"_q.arg(threadPostMatch->captured(1), threadPostMatch->captured(2));
} else if (const auto postMatch = regex_match(u"^/(\\d+)(/?\\?|/?$)"_q, privateMatch->captured(2))) { } else if (const auto postMatch = regex_match(u"^/(\\d+)(/?\\?|/?$)"_q, privateMatch->captured(2))) {
added = u"&post="_q + postMatch->captured(1); added = u"&post="_q + postMatch->captured(1);
} }
@ -1122,7 +1122,7 @@ QString TryConvertUrlToLocal(QString url) {
const auto base = u"tg://resolve?domain="_q + url_encode(usernameMatch->captured(1)); const auto base = u"tg://resolve?domain="_q + url_encode(usernameMatch->captured(1));
auto added = QString(); auto added = QString();
if (const auto threadPostMatch = regex_match(u"^/(\\d+)/(\\d+)(/?\\?|/?$)"_q, usernameMatch->captured(2))) { if (const auto threadPostMatch = regex_match(u"^/(\\d+)/(\\d+)(/?\\?|/?$)"_q, usernameMatch->captured(2))) {
added = u"&topic=%1&post=%2"_q.arg(threadPostMatch->captured(1)).arg(threadPostMatch->captured(2)); added = u"&topic=%1&post=%2"_q.arg(threadPostMatch->captured(1), threadPostMatch->captured(2));
} else if (const auto postMatch = regex_match(u"^/(\\d+)(/?\\?|/?$)"_q, usernameMatch->captured(2))) { } else if (const auto postMatch = regex_match(u"^/(\\d+)(/?\\?|/?$)"_q, usernameMatch->captured(2))) {
added = u"&post="_q + postMatch->captured(1); added = u"&post="_q + postMatch->captured(1);
} else if (const auto storyMatch = regex_match(u"^/s/(\\d+)(/?\\?|/?$)"_q, usernameMatch->captured(2))) { } else if (const auto storyMatch = regex_match(u"^/s/(\\d+)(/?\\?|/?$)"_q, usernameMatch->captured(2))) {

View file

@ -216,7 +216,7 @@ void Sandbox::setupScreenScale() {
const auto logEnv = [](const char *name) { const auto logEnv = [](const char *name) {
const auto value = qEnvironmentVariable(name); const auto value = qEnvironmentVariable(name);
if (!value.isEmpty()) { if (!value.isEmpty()) {
LOG(("%1: %2").arg(name).arg(value)); LOG(("%1: %2").arg(name, value));
} }
}; };
logEnv("QT_DEVICE_PIXEL_RATIO"); logEnv("QT_DEVICE_PIXEL_RATIO");

View file

@ -134,8 +134,9 @@ void PremultiplyLine(uchar *dst, const uchar *src, int intsCount) {
} }
DEBUG_LOG(("Video Info: " DEBUG_LOG(("Video Info: "
"Trying \"%1\" hardware acceleration for \"%2\" decoder." "Trying \"%1\" hardware acceleration for \"%2\" decoder."
).arg(av_hwdevice_get_type_name(type) ).arg(
).arg(context->codec->name)); av_hwdevice_get_type_name(type),
context->codec->name));
if (parent->hw_device_ctx) { if (parent->hw_device_ctx) {
av_buffer_unref(&parent->hw_device_ctx); av_buffer_unref(&parent->hw_device_ctx);
} }

View file

@ -82,8 +82,7 @@ enum class FilterType {
const auto durationString = Ui::FormatDurationText(duration / kPrecision); const auto durationString = Ui::FormatDurationText(duration / kPrecision);
const auto decimalPart = duration % kPrecision; const auto decimalPart = duration % kPrecision;
return QString("%1%2%3") return QString("%1%2%3")
.arg(durationString) .arg(durationString, QLocale().decimalPoint())
.arg(QLocale().decimalPoint())
.arg(decimalPart); .arg(decimalPart);
} }

View file

@ -85,8 +85,7 @@ void HttpConnection::connectToServer(
if (Logs::DebugEnabled()) { if (Logs::DebugEnabled()) {
_debugId = u"%1(dc:%2,%3)"_q _debugId = u"%1(dc:%2,%3)"_q
.arg(_debugId.toInt()) .arg(_debugId.toInt())
.arg(ProtocolDcDebugId(protocolDcId)) .arg(ProtocolDcDebugId(protocolDcId), url().toDisplayString());
.arg(url().toDisplayString());
} }
_pingTime = crl::now(); _pingTime = crl::now();

View file

@ -536,9 +536,10 @@ void TcpConnection::connectToServer(
const auto postfix = _socket->debugPostfix(); const auto postfix = _socket->debugPostfix();
_debugId = u"%1(dc:%2,%3%4:%5%6)"_q _debugId = u"%1(dc:%2,%3%4:%5%6)"_q
.arg(_debugId.toInt()) .arg(_debugId.toInt())
.arg(ProtocolDcDebugId(_protocolDcId)) .arg(
.arg((_proxy.type == ProxyData::Type::Mtproto) ? "mtproxy " : "") ProtocolDcDebugId(_protocolDcId),
.arg(_address) (_proxy.type == ProxyData::Type::Mtproto) ? "mtproxy " : "",
_address)
.arg(_port) .arg(_port)
.arg(postfix.isEmpty() ? _protocol->debugPostfix() : postfix); .arg(postfix.isEmpty() ? _protocol->debugPostfix() : postfix);
_socket->setDebugId(_debugId); _socket->setDebugId(_debugId);

View file

@ -985,8 +985,7 @@ void Form::validateCard(
if (error) { if (error) {
LOG(("Stripe Error %1: %2 (%3)" LOG(("Stripe Error %1: %2 (%3)"
).arg(int(error.code()) ).arg(int(error.code())
).arg(error.description() ).arg(error.description(), error.message()));
).arg(error.message()));
_updates.fire(Error{ Error::Type::Stripe, error.description() }); _updates.fire(Error{ Error::Type::Stripe, error.description() });
} else { } else {
setPaymentCredentials({ setPaymentCredentials({
@ -1036,8 +1035,7 @@ void Form::validateCard(
if (error) { if (error) {
LOG(("SmartGlocal Error %1: %2 (%3)" LOG(("SmartGlocal Error %1: %2 (%3)"
).arg(int(error.code()) ).arg(int(error.code())
).arg(error.description() ).arg(error.description(), error.message()));
).arg(error.message()));
_updates.fire(Error{ _updates.fire(Error{
Error::Type::SmartGlocal, Error::Type::SmartGlocal,
error.description(), error.description(),