aboutsummaryrefslogtreecommitdiff
path: root/launcher/Version.cpp
diff options
context:
space:
mode:
authorflow <flowlnlnln@gmail.com>2023-01-19 21:31:55 -0300
committerflow <flowlnlnln@gmail.com>2023-01-20 11:15:26 -0300
commit81848e05f100a135ad1d307ccabb796be0540daa (patch)
tree78972f42c73d64f8277eee2150cba05203a7b687 /launcher/Version.cpp
parent5ae69c079a15fa16945b306e29925e800cb28c87 (diff)
downloadPrismLauncher-81848e05f100a135ad1d307ccabb796be0540daa.tar.gz
PrismLauncher-81848e05f100a135ad1d307ccabb796be0540daa.tar.bz2
PrismLauncher-81848e05f100a135ad1d307ccabb796be0540daa.zip
refactor: simplify Version operators
Signed-off-by: flow <flowlnlnln@gmail.com>
Diffstat (limited to 'launcher/Version.cpp')
-rw-r--r--launcher/Version.cpp66
1 files changed, 26 insertions, 40 deletions
diff --git a/launcher/Version.cpp b/launcher/Version.cpp
index 9b96f68e..9307aab3 100644
--- a/launcher/Version.cpp
+++ b/launcher/Version.cpp
@@ -1,67 +1,41 @@
#include "Version.h"
#include <QDebug>
-#include <QUrl>
#include <QRegularExpression>
#include <QRegularExpressionMatch>
+#include <QUrl>
-Version::Version(const QString &str) : m_string(str)
+Version::Version(QString str) : m_string(std::move(str))
{
parse();
}
-bool Version::operator<(const Version &other) const
+bool Version::operator<(const Version& other) const
{
- const int size = qMax(m_sections.size(), other.m_sections.size());
- for (int i = 0; i < size; ++i)
- {
- const Section sec1 = (i >= m_sections.size()) ? Section("") : m_sections.at(i);
+ const auto size = qMax(m_sections.size(), other.m_sections.size());
+ for (int i = 0; i < size; ++i) {
+ const Section sec1 =
+ (i >= m_sections.size()) ? Section("") : m_sections.at(i);
const Section sec2 =
(i >= other.m_sections.size()) ? Section("") : other.m_sections.at(i);
+
if (sec1 != sec2)
- {
return sec1 < sec2;
- }
}
return false;
}
-bool Version::operator<=(const Version &other) const
-{
- return *this < other || *this == other;
-}
-bool Version::operator>(const Version &other) const
+bool Version::operator==(const Version& other) const
{
- const int size = qMax(m_sections.size(), other.m_sections.size());
- for (int i = 0; i < size; ++i)
- {
- const Section sec1 = (i >= m_sections.size()) ? Section("") : m_sections.at(i);
+ const auto size = qMax(m_sections.size(), other.m_sections.size());
+ for (int i = 0; i < size; ++i) {
+ const Section sec1 =
+ (i >= m_sections.size()) ? Section("") : m_sections.at(i);
const Section sec2 =
(i >= other.m_sections.size()) ? Section("") : other.m_sections.at(i);
- if (sec1 != sec2)
- {
- return sec1 > sec2;
- }
- }
- return false;
-}
-bool Version::operator>=(const Version &other) const
-{
- return *this > other || *this == other;
-}
-bool Version::operator==(const Version &other) const
-{
- const int size = qMax(m_sections.size(), other.m_sections.size());
- for (int i = 0; i < size; ++i)
- {
- const Section sec1 = (i >= m_sections.size()) ? Section("") : m_sections.at(i);
- const Section sec2 =
- (i >= other.m_sections.size()) ? Section("") : other.m_sections.at(i);
if (sec1 != sec2)
- {
return false;
- }
}
return true;
@@ -70,6 +44,18 @@ bool Version::operator!=(const Version &other) const
{
return !operator==(other);
}
+bool Version::operator<=(const Version &other) const
+{
+ return *this < other || *this == other;
+}
+bool Version::operator>(const Version &other) const
+{
+ return !(*this <= other);
+}
+bool Version::operator>=(const Version &other) const
+{
+ return !(*this < other);
+}
void Version::parse()
{
@@ -96,7 +82,7 @@ void Version::parse()
}
-/// qDebug print support for the BlockedMod struct
+/// qDebug print support for the Version class
QDebug operator<<(QDebug debug, const Version& v)
{
QDebugStateSaver saver(debug);