diff --git a/src/common/HighScoresManager.cxx b/src/common/HighScoresManager.cxx index 3af566ac9..5b34c8ebb 100644 --- a/src/common/HighScoresManager.cxx +++ b/src/common/HighScoresManager.cxx @@ -462,8 +462,8 @@ Int32 HighScoresManager::convert(Int32 val, uInt32 maxVal, bool isBCD, //maxVal += zeroBased ? 0 : 1; maxVal -= zeroBased ? 1 : 0; const Int32 bits = isBCD - ? ceil(log(maxVal) / log(10) * 4) - : ceil(log(maxVal) / log(2)); + ? ceil(log(maxVal) / std::numbers::ln10 * 4) + : ceil(log(maxVal) / std::numbers::ln2); // limit to maxVal's bits val %= 1 << bits; diff --git a/src/common/Variant.hxx b/src/common/Variant.hxx index 23794fba4..e5bd0ecfc 100644 --- a/src/common/Variant.hxx +++ b/src/common/Variant.hxx @@ -60,26 +60,17 @@ class Variant const string& toString() const { return data; } const char* toCString() const { return data.c_str(); } Int32 toInt() const { - istringstream ss(data); - Int32 parsed; - ss >> parsed; - - return parsed; + try { return std::stoi(data); } catch(...) { return 0; } } float toFloat() const { - istringstream ss(data); - float parsed; - ss >> parsed; - - return parsed; + try { return std::stof(data); } catch(...) { return 0.F; } } - bool toBool() const { return data == "1" || data == "true"; } + bool toBool() const { return data == "1" || data == "true"; } Common::Size toSize() const { return Common::Size(data); } Common::Point toPoint() const { return Common::Point(data); } // Comparison - bool operator==(const Variant& v) const { return data == v.data; } - bool operator!=(const Variant& v) const { return data != v.data; } + bool operator<=>(const Variant& v) const = default; friend ostream& operator<<(ostream& os, const Variant& v) { return os << v.data; diff --git a/src/emucore/QuadTari.cxx b/src/emucore/QuadTari.cxx index 3c3beefcf..c9585a32f 100644 --- a/src/emucore/QuadTari.cxx +++ b/src/emucore/QuadTari.cxx @@ -38,7 +38,6 @@ QuadTari::QuadTari(Jack jack, const OSystem& osystem, const System& system, myOSystem{osystem}, myProperties{properties} { - Controller::Type firstType, secondType; string first, second; if(jack == Controller::Jack::Left) @@ -51,8 +50,8 @@ QuadTari::QuadTari(Jack jack, const OSystem& osystem, const System& system, first = properties.get(PropType::Controller_Right1); second = properties.get(PropType::Controller_Right2); } - firstType = Controller::getType(first); - secondType = Controller::getType(second); + Controller::Type firstType = Controller::getType(first), + secondType = Controller::getType(second); // Autodetect QuadTari controllers: // This will detect the same controller for 1st and 2nd controller diff --git a/src/gui/QuadTariDialog.cxx b/src/gui/QuadTariDialog.cxx index 06afe9d20..7d164a32a 100644 --- a/src/gui/QuadTariDialog.cxx +++ b/src/gui/QuadTariDialog.cxx @@ -134,8 +134,6 @@ void QuadTariDialog::show(bool enableLeft, bool enableRight) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void QuadTariDialog::loadControllerProperties(const Properties& props) { - string controller; - if(myLeftPortLabel->isEnabled()) { defineController(props, PropType::Controller_Left1, Controller::Jack::Left, @@ -160,7 +158,7 @@ void QuadTariDialog::defineController(const Properties& props, PropType key, ByteBuffer image; size_t size = 0; - string controllerName = props.get(key); + const string& controllerName = props.get(key); popupWidget->setSelected(controllerName, "AUTO"); // try to load the image for auto detection @@ -173,7 +171,7 @@ void QuadTariDialog::defineController(const Properties& props, PropType key, && (image = instance().openROM(node, md5, size)) != nullptr; } string label; - Controller::Type type = Controller::getType(popupWidget->getSelectedTag().toString()); + const Controller::Type type = Controller::getType(popupWidget->getSelectedTag().toString()); if(type == Controller::Type::Unknown) { diff --git a/src/gui/RomImageWidget.cxx b/src/gui/RomImageWidget.cxx index 24b59d2be..7055db5ea 100644 --- a/src/gui/RomImageWidget.cxx +++ b/src/gui/RomImageWidget.cxx @@ -323,7 +323,7 @@ bool RomImageWidget::loadPng(const string& fileName) break; } if(data.first == "Software" - && data.second.toString().find("Stella") == 0) + && data.second.toString().starts_with("Stella")) myLabel = "Snapshot"; // default for Stella snapshots with missing "Title" meta data } return true;