Skip to content

Commit

Permalink
Merge pull request #2296 from barton2526/redundant
Browse files Browse the repository at this point in the history
refactor: Drop redundant QString calls
  • Loading branch information
jamescowens committed Aug 24, 2021
2 parents 9163cba + 92ef0d5 commit 6bc9e17
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/qt/guiutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,14 @@ QString dateTimeStr(qint64 nTime)

QString formatPingTime(double dPingTime)
{
return (dPingTime == std::numeric_limits<int64_t>::max()/1e6 || dPingTime == 0) ? QObject::tr("N/A") : QString(QObject::tr("%1 ms")).arg(QString::number((int)(dPingTime * 1000), 10));
return (dPingTime == std::numeric_limits<int64_t>::max()/1e6 || dPingTime == 0) ?
QObject::tr("N/A") :
QObject::tr("%1 ms").arg(QString::number((int)(dPingTime * 1000), 10));
}

QString formatTimeOffset(int64_t nTimeOffset)
{
return QString(QObject::tr("%1 s")).arg(QString::number((int)nTimeOffset, 10));
return QObject::tr("%1 s").arg(QString::number((int)nTimeOffset, 10));
}

QString formatNiceTimeOffset(qint64 secs)
Expand Down Expand Up @@ -105,13 +107,13 @@ QString formatNiceTimeOffset(qint64 secs)
QString formatBytes(uint64_t bytes)
{
if(bytes < 1024)
return QString(QObject::tr("%1 B")).arg(bytes);
return QObject::tr("%1 B").arg(bytes);
if(bytes < 1024 * 1024)
return QString(QObject::tr("%1 KB")).arg(bytes / 1024);
return QObject::tr("%1 KB").arg(bytes / 1024);
if(bytes < 1024 * 1024 * 1024)
return QString(QObject::tr("%1 MB")).arg(bytes / 1024 / 1024);
return QObject::tr("%1 MB").arg(bytes / 1024 / 1024);

return QString(QObject::tr("%1 GB")).arg(bytes / 1024 / 1024 / 1024);
return QObject::tr("%1 GB").arg(bytes / 1024 / 1024 / 1024);
}

QString formatDurationStr(int secs)
Expand All @@ -123,13 +125,13 @@ QString formatDurationStr(int secs)
int seconds = secs % 60;

if (days)
strList.append(QString(QObject::tr("%1 d")).arg(days));
strList.append(QObject::tr("%1 d").arg(days));
if (hours)
strList.append(QString(QObject::tr("%1 h")).arg(hours));
strList.append(QObject::tr("%1 h").arg(hours));
if (mins)
strList.append(QString(QObject::tr("%1 m")).arg(mins));
strList.append(QObject::tr("%1 m").arg(mins));
if (seconds || (!days && !hours && !mins))
strList.append(QString(QObject::tr("%1 s")).arg(seconds));
strList.append(QObject::tr("%1 s").arg(seconds));

return strList.join(" ");
}
Expand Down

0 comments on commit 6bc9e17

Please sign in to comment.