From 64ed418bb57e215c23cd0d142ab0f76b69a2a878 Mon Sep 17 00:00:00 2001 From: Stephen Anthony Date: Wed, 21 Dec 2022 20:36:35 -0330 Subject: [PATCH] And a few more string_view conversions. --- src/debugger/gui/CartE7Widget.cxx | 13 ++++++------- src/debugger/gui/CartE7Widget.hxx | 4 ++-- src/emucore/Thumbulator.cxx | 9 +++++---- src/emucore/Thumbulator.hxx | 4 ++-- src/os/windows/FSNodeWINDOWS.cxx | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/debugger/gui/CartE7Widget.cxx b/src/debugger/gui/CartE7Widget.cxx index 19c0e53db..b1741f9d6 100644 --- a/src/debugger/gui/CartE7Widget.cxx +++ b/src/debugger/gui/CartE7Widget.cxx @@ -202,16 +202,16 @@ uInt8 CartridgeE7Widget::internalRamGetValue(int addr) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -const char* CartridgeE7Widget::getSpotLower(int idx) +string_view CartridgeE7Widget::getSpotLower(int idx) const { - static constexpr std::array spot_lower_8K = { + static constexpr std::array spot_lower_8K = { "#0 - ROM ($FFE4)", "#1 - ROM ($FFE5)", "#2 - ROM ($FFE6)", "#3 - RAM ($FFE7)" }; - static constexpr std::array spot_lower_12K = { + static constexpr std::array spot_lower_12K = { "#0 - ROM ($FFE0)", "#1 - ROM ($FFE1)", "#2 - ROM ($FFE4)", "#3 - ROM ($FFE5)", "#4 - ROM ($FFE6)", "#5 - RAM ($FFE7)" }; - static constexpr std::array spot_lower_16K = { + static constexpr std::array spot_lower_16K = { "#0 - ROM ($FFE0)", "#1 - ROM ($FFE1)", "#2 - ROM ($FFE2)", "#3 - ROM ($FFE3)", "#4 - ROM ($FFE4)", "#5 - ROM ($FFE5)", "#6 - ROM ($FFE6)", "#7 - RAM ($FFE7)" }; @@ -225,12 +225,11 @@ const char* CartridgeE7Widget::getSpotLower(int idx) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -const char* CartridgeE7Widget::getSpotUpper(int idx) +string_view CartridgeE7Widget::getSpotUpper(int idx) const { - static constexpr std::array spot_upper = { + static constexpr std::array spot_upper = { "#0 - RAM ($FFE8)", "#1 - RAM ($FFE9)", "#2 - RAM ($FFEA)", "#3 - RAM ($FFEB)" }; return spot_upper[idx]; } - diff --git a/src/debugger/gui/CartE7Widget.hxx b/src/debugger/gui/CartE7Widget.hxx index fe7f760c6..6c124a38e 100644 --- a/src/debugger/gui/CartE7Widget.hxx +++ b/src/debugger/gui/CartE7Widget.hxx @@ -54,8 +54,8 @@ class CartridgeE7Widget : public CartDebugWidget protected: void initialize(GuiObject* boss, const CartridgeE7& cart, const ostringstream& info); - const char* getSpotLower(int idx); - static const char* getSpotUpper(int idx); + string_view getSpotLower(int idx) const; + string_view getSpotUpper(int idx) const; private: void saveOldState() override; diff --git a/src/emucore/Thumbulator.cxx b/src/emucore/Thumbulator.cxx index fd3fc8bbe..67258c811 100644 --- a/src/emucore/Thumbulator.cxx +++ b/src/emucore/Thumbulator.cxx @@ -243,7 +243,7 @@ string Thumbulator::run(uInt32& cycles, bool irqDrivenAudio) #ifndef UNSAFE_OPTIMIZATIONS // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -int Thumbulator::fatalError(const char* opcode, uInt32 v1, const char* msg) +int Thumbulator::fatalError(string_view opcode, uInt32 v1, string_view msg) { statusMsg << "Thumb ARM emulation fatal error: " << endl << opcode << "(" << Base::HEX8 << v1 << "), " << msg << endl; @@ -254,11 +254,12 @@ int Thumbulator::fatalError(const char* opcode, uInt32 v1, const char* msg) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -int Thumbulator::fatalError(const char* opcode, uInt32 v1, uInt32 v2, - const char* msg) +int Thumbulator::fatalError(string_view opcode, uInt32 v1, uInt32 v2, + string_view msg) { statusMsg << "Thumb ARM emulation fatal error: " << endl - << opcode << "(" << Base::HEX8 << v1 << "," << v2 << "), " << msg << endl; + << opcode << "(" << Base::HEX8 << v1 << "," << v2 << "), " << msg + << endl; dump_regs(); if(trapOnFatal) throw runtime_error(statusMsg.str()); diff --git a/src/emucore/Thumbulator.hxx b/src/emucore/Thumbulator.hxx index e4ce58381..cabd9af5c 100644 --- a/src/emucore/Thumbulator.hxx +++ b/src/emucore/Thumbulator.hxx @@ -239,8 +239,8 @@ class Thumbulator // Throw a runtime_error exception containing an error referencing the // given message and variables // Note that the return value is never used in these methods - int fatalError(const char* opcode, uInt32 v1, const char* msg); - int fatalError(const char* opcode, uInt32 v1, uInt32 v2, const char* msg); + int fatalError(string_view opcode, uInt32 v1, string_view msg); + int fatalError(string_view opcode, uInt32 v1, uInt32 v2, string_view msg); void dump_counters() const; void dump_regs(); diff --git a/src/os/windows/FSNodeWINDOWS.cxx b/src/os/windows/FSNodeWINDOWS.cxx index c16b1a8a4..9ecc767c9 100644 --- a/src/os/windows/FSNodeWINDOWS.cxx +++ b/src/os/windows/FSNodeWINDOWS.cxx @@ -77,7 +77,7 @@ string FSNodeWINDOWS::getShortPath() const if (home != "" && BSPF::startsWithIgnoreCase(_path, home)) { string path = "~"; - const char* const offset = _path.c_str() + home.length(); + const char* const offset = _path.c_str() + home.size(); if (*offset != FSNode::PATH_SEPARATOR) path += FSNode::PATH_SEPARATOR; path += offset;