From 084fea220e36c422761d159885e1f0724e5a6a53 Mon Sep 17 00:00:00 2001 From: dankmeme01 <42031238+dankmeme01@users.noreply.github.com> Date: Sun, 10 Nov 2024 16:05:20 +0100 Subject: [PATCH] code cleanup: remove unnecessary const in function parameters --- loader/include/Geode/c++stl/string.hpp | 4 +-- loader/include/Geode/loader/Loader.hpp | 8 +++--- loader/include/Geode/loader/Mod.hpp | 28 +++++++++---------- loader/include/Geode/ui/TextArea.hpp | 24 ++++++++-------- loader/include/Geode/utils/Task.hpp | 20 ++++++------- loader/include/Geode/utils/general.hpp | 2 +- loader/src/c++stl/string-impl.hpp | 2 +- loader/src/c++stl/string.cpp | 4 +-- loader/src/loader/Loader.cpp | 6 ++-- loader/src/loader/LoaderImpl.cpp | 6 ++-- loader/src/loader/LoaderImpl.hpp | 6 ++-- loader/src/loader/Mod.cpp | 14 +++++----- loader/src/loader/ModImpl.cpp | 12 ++++---- loader/src/loader/ModImpl.hpp | 12 ++++---- loader/src/platform/android/gdstdlib.cpp | 2 +- .../src/platform/windows/gdTimestampMap.hpp | 2 +- loader/src/ui/nodes/TextArea.cpp | 28 +++++++++---------- loader/src/utils/web.cpp | 2 +- 18 files changed, 91 insertions(+), 91 deletions(-) diff --git a/loader/include/Geode/c++stl/string.hpp b/loader/include/Geode/c++stl/string.hpp index 6b8ca914..c84caa15 100644 --- a/loader/include/Geode/c++stl/string.hpp +++ b/loader/include/Geode/c++stl/string.hpp @@ -93,7 +93,7 @@ namespace gd { bool empty() const; bool operator==(string const& other) const; - bool operator==(std::string_view const other) const; + bool operator==(std::string_view other) const; bool operator==(char const* other) const { return *this == std::string_view(other); } @@ -101,7 +101,7 @@ namespace gd { return *this == std::string_view(other); } std::strong_ordering operator<=>(string const& other) const; - std::strong_ordering operator<=>(std::string_view const other) const; + std::strong_ordering operator<=>(std::string_view other) const; std::strong_ordering operator<=>(char const* other) const { return *this <=> std::string_view(other); } diff --git a/loader/include/Geode/loader/Loader.hpp b/loader/include/Geode/loader/Loader.hpp index e907dc1a..1ee17351 100644 --- a/loader/include/Geode/loader/Loader.hpp +++ b/loader/include/Geode/loader/Loader.hpp @@ -103,26 +103,26 @@ namespace geode { * Returns whether the specified launch argument was passed in via the command line. * @param name The argument name */ - bool hasLaunchArgument(std::string_view const name) const; + bool hasLaunchArgument(std::string_view name) const; /** * Get a launch argument. These are passed into the game as command-line arguments * with the format `--geode:arg-name=value`. * @param name The argument name * @return The value, if present */ - std::optional getLaunchArgument(std::string_view const name) const; + std::optional getLaunchArgument(std::string_view name) const; /** * Get a launch argument flag. Returns whether the argument is present and its * value is exactly `true`. * @param name The argument name */ - bool getLaunchFlag(std::string_view const name) const; + bool getLaunchFlag(std::string_view name) const; /** * Get and parse a launch argument value using the setting value system. * @param name The argument name */ template - Result parseLaunchArgument(std::string_view const name) const { + Result parseLaunchArgument(std::string_view name) const { auto str = this->getLaunchArgument(name); if (!str.has_value()) { return Err(fmt::format("Launch argument '{}' not found", name)); diff --git a/loader/include/Geode/loader/Mod.hpp b/loader/include/Geode/loader/Mod.hpp index b4dfe12d..c174f7e3 100644 --- a/loader/include/Geode/loader/Mod.hpp +++ b/loader/include/Geode/loader/Mod.hpp @@ -155,7 +155,7 @@ namespace geode { * declared in `mod.json`) */ std::vector getSettingKeys() const; - bool hasSetting(std::string_view const key) const; + bool hasSetting(std::string_view key) const; /** * Get the definition of a setting, or null if the setting was not found, @@ -163,7 +163,7 @@ namespace geode { * `Mod::registerCustomSettingType` * @param key The key of the setting as defined in `mod.json` */ - std::shared_ptr getSetting(std::string_view const key) const; + std::shared_ptr getSetting(std::string_view key) const; /** * Register a custom setting type. See @@ -179,7 +179,7 @@ namespace geode { * Returns a prefixed launch argument name. See `Mod::getLaunchArgument` * for details about mod-specific launch arguments. */ - std::string getLaunchArgumentName(std::string_view const name) const; + std::string getLaunchArgumentName(std::string_view name) const; /** * Returns the names of the available mod-specific launch arguments. */ @@ -189,7 +189,7 @@ namespace geode { * for details about mod-specific launch arguments. * @param name The argument name */ - bool hasLaunchArgument(std::string_view const name) const; + bool hasLaunchArgument(std::string_view name) const; /** * Get a mod-specific launch argument. This is equivalent to `Loader::getLaunchArgument` * with the argument name prefixed by the mod ID. For example, a launch argument named @@ -197,20 +197,20 @@ namespace geode { * @param name The argument name * @return The value, if present */ - std::optional getLaunchArgument(std::string_view const name) const; + std::optional getLaunchArgument(std::string_view name) const; /** * Equivalent to a prefixed `Loader::getLaunchFlag` call. See `Mod::getLaunchArgument` * for details about mod-specific launch arguments. * @param name The argument name */ - bool getLaunchFlag(std::string_view const name) const; + bool getLaunchFlag(std::string_view name) const; /** * Equivalent to a prefixed `Loader::parseLaunchArgument` call. See `Mod::getLaunchArgument` * for details about mod-specific launch arguments. * @param name The argument name */ template - std::optional parseLaunchArgument(std::string_view const name) const { + std::optional parseLaunchArgument(std::string_view name) const { return Loader::get()->parseLaunchArgument(this->getLaunchArgumentName(name)); } @@ -224,7 +224,7 @@ namespace geode { * setting type has a `getValue` function which returns the value */ template - T getSettingValue(std::string_view const key) const { + T getSettingValue(std::string_view key) const { using S = typename SettingTypeForValueType::SettingType; if (auto sett = cast::typeinfo_pointer_cast(this->getSetting(key))) { return sett->getValue(); @@ -233,7 +233,7 @@ namespace geode { } template - T setSettingValue(std::string_view const key, T const& value) { + T setSettingValue(std::string_view key, T const& value) { using S = typename SettingTypeForValueType::SettingType; if (auto sett = cast::typeinfo_pointer_cast(this->getSetting(key))) { auto old = sett->getValue(); @@ -243,10 +243,10 @@ namespace geode { return T(); } - bool hasSavedValue(std::string_view const key); + bool hasSavedValue(std::string_view key); template - T getSavedValue(std::string_view const key) { + T getSavedValue(std::string_view key) { auto& saved = this->getSaveContainer(); if (auto res = saved.get(key).andThen([](auto&& v) { return v.template as(); @@ -257,7 +257,7 @@ namespace geode { } template - T getSavedValue(std::string_view const key, T const& defaultValue) { + T getSavedValue(std::string_view key, T const& defaultValue) { auto& saved = this->getSaveContainer(); if (auto res = saved.get(key).andThen([](auto&& v) { return v.template as(); @@ -276,7 +276,7 @@ namespace geode { * @returns The old value */ template - T setSavedValue(std::string_view const key, T const& value) { + T setSavedValue(std::string_view key, T const& value) { auto& saved = this->getSaveContainer(); auto old = this->getSavedValue(key); saved[key] = value; @@ -417,7 +417,7 @@ namespace geode { * Check whether or not this Mod * depends on another mod */ - bool depends(std::string_view const id) const; + bool depends(std::string_view id) const; /** * Check whether all the required diff --git a/loader/include/Geode/ui/TextArea.hpp b/loader/include/Geode/ui/TextArea.hpp index 05b1f6da..7d9125fc 100644 --- a/loader/include/Geode/ui/TextArea.hpp +++ b/loader/include/Geode/ui/TextArea.hpp @@ -24,34 +24,34 @@ namespace geode { */ class GEODE_DLL SimpleTextArea : public cocos2d::CCNode { public: - static SimpleTextArea* create(const std::string& text, const std::string& font = "chatFont.fnt", const float scale = 1); - static SimpleTextArea* create(const std::string& text, const std::string& font, const float scale, const float width); + static SimpleTextArea* create(const std::string& text, const std::string& font = "chatFont.fnt", float scale = 1.0f); + static SimpleTextArea* create(const std::string& text, const std::string& font, float scale, float width); void setFont(const std::string& font); std::string getFont(); void setColor(const cocos2d::ccColor4B& color); cocos2d::ccColor4B getColor(); - void setAlignment(const cocos2d::CCTextAlignment alignment); + void setAlignment(cocos2d::CCTextAlignment alignment); cocos2d::CCTextAlignment getAlignment(); - void setWrappingMode(const WrappingMode mode); + void setWrappingMode(WrappingMode mode); WrappingMode getWrappingMode(); void setText(const std::string& text); std::string getText(); - void setMaxLines(const size_t maxLines); + void setMaxLines(size_t maxLines); size_t getMaxLines(); - void setWidth(const float width); + void setWidth(float width); float getWidth(); - void setScale(const float scale) override; + void setScale(float scale) override; float getScale() override; - void setLinePadding(const float padding); + void setLinePadding(float padding); float getLinePadding(); std::vector getLines(); float getHeight(); float getLineHeight(); private: - static SimpleTextArea* create(const std::string& font, const std::string& text, const float scale, const float width, const bool artificialWidth); + static SimpleTextArea* create(const std::string& font, const std::string& text, float scale, float width, const bool artificialWidth); - bool init(const std::string& font, const std::string& text, const float scale, const float width, const bool artificialWidth); + bool init(const std::string& font, const std::string& text, float scale, float width, const bool artificialWidth); bool m_shouldUpdate = false; bool m_artificialWidth = false; @@ -67,9 +67,9 @@ namespace geode { float m_lineHeight = 0.f; float m_linePadding = 0.f; - cocos2d::CCLabelBMFont* createLabel(const std::string& text, const float top); + cocos2d::CCLabelBMFont* createLabel(const std::string& text, float top); float calculateOffset(cocos2d::CCLabelBMFont* label); - void charIteration(const std::function& overflowHandling); + void charIteration(const std::function& overflowHandling); void updateLinesNoWrap(); void updateLinesWordWrap(bool spaceWrap); void updateLinesCutoffWrap(); diff --git a/loader/include/Geode/utils/Task.hpp b/loader/include/Geode/utils/Task.hpp index c2890be1..83ccd5ab 100644 --- a/loader/include/Geode/utils/Task.hpp +++ b/loader/include/Geode/utils/Task.hpp @@ -140,7 +140,7 @@ namespace geode { class PrivateMarker final {}; - static std::shared_ptr create(std::string_view const name) { + static std::shared_ptr create(std::string_view name) { return std::make_shared(PrivateMarker(), name); } @@ -153,7 +153,7 @@ namespace geode { friend class Task; public: - Handle(PrivateMarker, std::string_view const name) : m_name(name) {} + Handle(PrivateMarker, std::string_view name) : m_name(name) {} ~Handle() { // If this Task was still pending when the Handle was destroyed, // it can no longer be listened to so just cancel and cleanup @@ -393,7 +393,7 @@ namespace geode { * Create a new Task that is immediately cancelled * @param name The name of the Task; used for debugging */ - static Task cancelled(std::string_view const name = "") { + static Task cancelled(std::string_view name = "") { auto task = Task(Handle::create(name)); Task::cancel(task.m_handle); return task; @@ -404,7 +404,7 @@ namespace geode { * @param value The value the Task shall be finished with * @param name The name of the Task; used for debugging */ - static Task immediate(T value, std::string_view const name = "") { + static Task immediate(T value, std::string_view name = "") { auto task = Task(Handle::create(name)); Task::finish(task.m_handle, std::move(value)); return task; @@ -416,7 +416,7 @@ namespace geode { * function MUST be synchronous - Task creates the thread for you! * @param name The name of the Task; used for debugging */ - static Task run(Run&& body, std::string_view const name = "") { + static Task run(Run&& body, std::string_view name = "") { auto task = Task(Handle::create(name)); std::thread([handle = std::weak_ptr(task.m_handle), name = std::string(name), body = std::move(body)] { utils::thread::setName(fmt::format("Task '{}'", name)); @@ -449,7 +449,7 @@ namespace geode { * calls will always be ignored * @param name The name of the Task; used for debugging */ - static Task runWithCallback(RunWithCallback&& body, std::string_view const name = "") { + static Task runWithCallback(RunWithCallback&& body, std::string_view name = "") { auto task = Task(Handle::create(name)); std::thread([handle = std::weak_ptr(task.m_handle), name = std::string(name), body = std::move(body)] { utils::thread::setName(fmt::format("Task '{}'", name)); @@ -484,7 +484,7 @@ namespace geode { * were cancelled! */ template - static Task, std::monostate> all(std::vector>&& tasks, std::string_view const name = "") { + static Task, std::monostate> all(std::vector>&& tasks, std::string_view name = "") { using AllTask = Task, std::monostate>; // If there are no tasks, return an immediate task that does nothing @@ -581,7 +581,7 @@ namespace geode { * the mapped task is appended to the end */ template - auto map(ResultMapper&& resultMapper, ProgressMapper&& progressMapper, OnCancelled&& onCancelled, std::string_view const name = "") const { + auto map(ResultMapper&& resultMapper, ProgressMapper&& progressMapper, OnCancelled&& onCancelled, std::string_view name = "") const { using T2 = decltype(resultMapper(std::declval())); using P2 = decltype(progressMapper(std::declval())); @@ -651,7 +651,7 @@ namespace geode { * @param name The name of the Task; used for debugging. The name of * the mapped task is appended to the end */ template - auto map(ResultMapper&& resultMapper, ProgressMapper&& progressMapper, std::string_view const name = "") const { + auto map(ResultMapper&& resultMapper, ProgressMapper&& progressMapper, std::string_view name = "") const { return this->map(std::move(resultMapper), std::move(progressMapper), +[]() {}, name); } @@ -669,7 +669,7 @@ namespace geode { * the mapped task is appended to the end */ template requires std::copy_constructible

- auto map(ResultMapper&& resultMapper, std::string_view const name = "") const { + auto map(ResultMapper&& resultMapper, std::string_view name = "") const { return this->map(std::move(resultMapper), +[](P* p) -> P { return *p; }, name); } diff --git a/loader/include/Geode/utils/general.hpp b/loader/include/Geode/utils/general.hpp index 78298810..27844896 100644 --- a/loader/include/Geode/utils/general.hpp +++ b/loader/include/Geode/utils/general.hpp @@ -117,7 +117,7 @@ namespace geode { * @returns String as number, or Err if the string couldn't be converted */ template - Result numFromString(std::string_view const str, int base = 10) { + Result numFromString(std::string_view str, int base = 10) { if constexpr (std::is_floating_point_v #if defined(__cpp_lib_to_chars) && false diff --git a/loader/src/c++stl/string-impl.hpp b/loader/src/c++stl/string-impl.hpp index 99abf1e2..00335593 100644 --- a/loader/src/c++stl/string-impl.hpp +++ b/loader/src/c++stl/string-impl.hpp @@ -13,7 +13,7 @@ namespace geode::stl { void free(); char* getStorage(); - void setStorage(const std::string_view); + void setStorage(std::string_view); size_t getSize(); void setSize(size_t); diff --git a/loader/src/c++stl/string.cpp b/loader/src/c++stl/string.cpp index 7c7f18d9..83c5fe2e 100644 --- a/loader/src/c++stl/string.cpp +++ b/loader/src/c++stl/string.cpp @@ -100,11 +100,11 @@ namespace gd { bool string::operator==(string const& other) const { return std::string_view(*this) == std::string_view(other); } - bool string::operator==(std::string_view const other) const { + bool string::operator==(std::string_view other) const { return std::string_view(*this) == other; } - std::strong_ordering string::operator<=>(std::string_view const other) const { + std::strong_ordering string::operator<=>(std::string_view other) const { return static_cast(std::string_view(*this).compare(other) <=> 0); } diff --git a/loader/src/loader/Loader.cpp b/loader/src/loader/Loader.cpp index cd887d15..38761b52 100644 --- a/loader/src/loader/Loader.cpp +++ b/loader/src/loader/Loader.cpp @@ -119,14 +119,14 @@ std::vector Loader::getLaunchArgumentNames() const { return m_impl->getLaunchArgumentNames(); } -bool Loader::hasLaunchArgument(std::string_view const name) const { +bool Loader::hasLaunchArgument(std::string_view name) const { return m_impl->hasLaunchArgument(name); } -std::optional Loader::getLaunchArgument(std::string_view const name) const { +std::optional Loader::getLaunchArgument(std::string_view name) const { return m_impl->getLaunchArgument(name); } -bool Loader::getLaunchFlag(std::string_view const name) const { +bool Loader::getLaunchFlag(std::string_view name) const { return m_impl->getLaunchFlag(name); } diff --git a/loader/src/loader/LoaderImpl.cpp b/loader/src/loader/LoaderImpl.cpp index 54c938a4..1806eb6a 100644 --- a/loader/src/loader/LoaderImpl.cpp +++ b/loader/src/loader/LoaderImpl.cpp @@ -927,11 +927,11 @@ std::vector Loader::Impl::getLaunchArgumentNames() const { return map::keys(m_launchArgs); } -bool Loader::Impl::hasLaunchArgument(std::string_view const name) const { +bool Loader::Impl::hasLaunchArgument(std::string_view name) const { return m_launchArgs.find(std::string(name)) != m_launchArgs.end(); } -std::optional Loader::Impl::getLaunchArgument(std::string_view const name) const { +std::optional Loader::Impl::getLaunchArgument(std::string_view name) const { auto value = m_launchArgs.find(std::string(name)); if (value == m_launchArgs.end()) { return std::nullopt; @@ -939,7 +939,7 @@ std::optional Loader::Impl::getLaunchArgument(std::string_view cons return std::optional(value->second); } -bool Loader::Impl::getLaunchFlag(std::string_view const name) const { +bool Loader::Impl::getLaunchFlag(std::string_view name) const { auto arg = this->getLaunchArgument(name); return arg.has_value() && arg.value() == "true"; } diff --git a/loader/src/loader/LoaderImpl.hpp b/loader/src/loader/LoaderImpl.hpp index 7af233d5..b44b5d48 100644 --- a/loader/src/loader/LoaderImpl.hpp +++ b/loader/src/loader/LoaderImpl.hpp @@ -115,9 +115,9 @@ namespace geode { std::string getLaunchCommand() const; void initLaunchArguments(); std::vector getLaunchArgumentNames() const; - bool hasLaunchArgument(std::string_view const name) const; - std::optional getLaunchArgument(std::string_view const name) const; - bool getLaunchFlag(std::string_view const name) const; + bool hasLaunchArgument(std::string_view name) const; + std::optional getLaunchArgument(std::string_view name) const; + bool getLaunchFlag(std::string_view name) const; void updateResources(bool forceReload); diff --git a/loader/src/loader/Mod.cpp b/loader/src/loader/Mod.cpp index 272e7a9e..e3e7bd7f 100644 --- a/loader/src/loader/Mod.cpp +++ b/loader/src/loader/Mod.cpp @@ -148,11 +148,11 @@ std::vector Mod::getSettingKeys() const { return m_impl->getSettingKeys(); } -bool Mod::hasSetting(std::string_view const key) const { +bool Mod::hasSetting(std::string_view key) const { return m_impl->hasSetting(key); } -std::shared_ptr Mod::getSetting(std::string_view const key) const { +std::shared_ptr Mod::getSetting(std::string_view key) const { return m_impl->m_settings->get(std::string(key)); } @@ -164,15 +164,15 @@ std::vector Mod::getLaunchArgumentNames() const { return m_impl->getLaunchArgumentNames(); } -bool Mod::hasLaunchArgument(std::string_view const name) const { +bool Mod::hasLaunchArgument(std::string_view name) const { return m_impl->hasLaunchArgument(name); } -std::optional Mod::getLaunchArgument(std::string_view const name) const { +std::optional Mod::getLaunchArgument(std::string_view name) const { return m_impl->getLaunchArgument(name); } -bool Mod::getLaunchFlag(std::string_view const name) const { +bool Mod::getLaunchFlag(std::string_view name) const { return m_impl->getLaunchFlag(name); } @@ -220,7 +220,7 @@ ModRequestedAction Mod::getRequestedAction() const { return m_impl->getRequestedAction(); } -bool Mod::depends(std::string_view const id) const { +bool Mod::depends(std::string_view id) const { return m_impl->depends(id); } @@ -248,7 +248,7 @@ void Mod::setLoggingEnabled(bool enabled) { m_impl->setLoggingEnabled(enabled); } -bool Mod::hasSavedValue(std::string_view const key) { +bool Mod::hasSavedValue(std::string_view key) { return this->getSaveContainer().contains(key); } diff --git a/loader/src/loader/ModImpl.cpp b/loader/src/loader/ModImpl.cpp index dccea06a..01c7fada 100644 --- a/loader/src/loader/ModImpl.cpp +++ b/loader/src/loader/ModImpl.cpp @@ -243,7 +243,7 @@ std::vector Mod::Impl::getSettingKeys() const { return keys; } -bool Mod::Impl::hasSetting(std::string_view const key) const { +bool Mod::Impl::hasSetting(std::string_view key) const { for (auto& setting : m_metadata.getSettings()) { if (setting.first == key) { return true; @@ -252,7 +252,7 @@ bool Mod::Impl::hasSetting(std::string_view const key) const { return false; } -std::string Mod::Impl::getLaunchArgumentName(std::string_view const name) const { +std::string Mod::Impl::getLaunchArgumentName(std::string_view name) const { return this->getID() + "." + std::string(name); } @@ -267,15 +267,15 @@ std::vector Mod::Impl::getLaunchArgumentNames() const { return names; } -bool Mod::Impl::hasLaunchArgument(std::string_view const name) const { +bool Mod::Impl::hasLaunchArgument(std::string_view name) const { return Loader::get()->hasLaunchArgument(this->getLaunchArgumentName(name)); } -std::optional Mod::Impl::getLaunchArgument(std::string_view const name) const { +std::optional Mod::Impl::getLaunchArgument(std::string_view name) const { return Loader::get()->getLaunchArgument(this->getLaunchArgumentName(name)); } -bool Mod::Impl::getLaunchFlag(std::string_view const name) const { +bool Mod::Impl::getLaunchFlag(std::string_view name) const { return Loader::get()->getLaunchFlag(this->getLaunchArgumentName(name)); } @@ -442,7 +442,7 @@ bool Mod::Impl::hasUnresolvedIncompatibilities() const { return false; } -bool Mod::Impl::depends(std::string_view const id) const { +bool Mod::Impl::depends(std::string_view id) const { return utils::ranges::contains(m_metadata.getDependencies(), [id](ModMetadata::Dependency const& t) { return t.id == id; }); diff --git a/loader/src/loader/ModImpl.hpp b/loader/src/loader/ModImpl.hpp index cf709567..b3fb8dad 100644 --- a/loader/src/loader/ModImpl.hpp +++ b/loader/src/loader/ModImpl.hpp @@ -112,13 +112,13 @@ namespace geode { bool hasSettings() const; std::vector getSettingKeys() const; - bool hasSetting(std::string_view const key) const; + bool hasSetting(std::string_view key) const; - std::string getLaunchArgumentName(std::string_view const name) const; + std::string getLaunchArgumentName(std::string_view name) const; std::vector getLaunchArgumentNames() const; - bool hasLaunchArgument(std::string_view const name) const; - std::optional getLaunchArgument(std::string_view const name) const; - bool getLaunchFlag(std::string_view const name) const; + bool hasLaunchArgument(std::string_view name) const; + std::optional getLaunchArgument(std::string_view name) const; + bool getLaunchFlag(std::string_view name) const; Result claimHook(std::shared_ptr hook); Result<> disownHook(Hook* hook); @@ -136,7 +136,7 @@ namespace geode { // 1.3.0 additions ModRequestedAction getRequestedAction() const; - bool depends(std::string_view const id) const; + bool depends(std::string_view id) const; Result<> updateDependencies(); bool hasUnresolvedDependencies() const; bool hasUnresolvedIncompatibilities() const; diff --git a/loader/src/platform/android/gdstdlib.cpp b/loader/src/platform/android/gdstdlib.cpp index 3477b6dd..3559a8e5 100644 --- a/loader/src/platform/android/gdstdlib.cpp +++ b/loader/src/platform/android/gdstdlib.cpp @@ -101,7 +101,7 @@ namespace geode::stl { } // TODO: add a copyFrom(string const&) to take advantage // of gnustl refcounted strings - void StringImpl::setStorage(const std::string_view str) { + void StringImpl::setStorage(std::string_view str) { this->free(); if (str.size() == 0) { diff --git a/loader/src/platform/windows/gdTimestampMap.hpp b/loader/src/platform/windows/gdTimestampMap.hpp index 5afc8618..27d0c430 100644 --- a/loader/src/platform/windows/gdTimestampMap.hpp +++ b/loader/src/platform/windows/gdTimestampMap.hpp @@ -49,7 +49,7 @@ static std::string timestampToVersion(uint32_t timestamp) { } } -static uint32_t versionToTimestamp(std::string_view const targetVersion) { +static uint32_t versionToTimestamp(std::string_view targetVersion) { for (const auto& [stamp, ver] : getGDVersionTimestampMap()) { if (ver == targetVersion) { return stamp; diff --git a/loader/src/ui/nodes/TextArea.cpp b/loader/src/ui/nodes/TextArea.cpp index c46384ff..90cb7aea 100644 --- a/loader/src/ui/nodes/TextArea.cpp +++ b/loader/src/ui/nodes/TextArea.cpp @@ -2,15 +2,15 @@ using namespace geode::prelude; -SimpleTextArea* SimpleTextArea::create(const std::string& text, const std::string& font, const float scale) { +SimpleTextArea* SimpleTextArea::create(const std::string& text, const std::string& font, float scale) { return SimpleTextArea::create(font, text, scale, CCDirector::sharedDirector()->getWinSize().width / 2, false); } -SimpleTextArea* SimpleTextArea::create(const std::string& text, const std::string& font, const float scale, const float width) { +SimpleTextArea* SimpleTextArea::create(const std::string& text, const std::string& font, float scale, float width) { return SimpleTextArea::create(font, text, scale, width, true); } -SimpleTextArea* SimpleTextArea::create(const std::string& font, const std::string& text, const float scale, const float width, const bool artificialWidth) { +SimpleTextArea* SimpleTextArea::create(const std::string& font, const std::string& text, float scale, float width, bool artificialWidth) { SimpleTextArea* instance = new SimpleTextArea(); if (instance->init(font, text, scale, width, artificialWidth)) { @@ -22,7 +22,7 @@ SimpleTextArea* SimpleTextArea::create(const std::string& font, const std::strin return nullptr; } -bool SimpleTextArea::init(const std::string& font, const std::string& text, const float scale, const float width, const bool artificialWidth) { +bool SimpleTextArea::init(const std::string& font, const std::string& text, float scale, float width, bool artificialWidth) { m_font = font; m_text = text; m_scale = scale; @@ -57,7 +57,7 @@ ccColor4B SimpleTextArea::getColor() { return m_color; } -void SimpleTextArea::setAlignment(const CCTextAlignment alignment) { +void SimpleTextArea::setAlignment(CCTextAlignment alignment) { m_alignment = alignment; this->updateContainer(); } @@ -66,7 +66,7 @@ CCTextAlignment SimpleTextArea::getAlignment() { return m_alignment; } -void SimpleTextArea::setWrappingMode(const WrappingMode mode) { +void SimpleTextArea::setWrappingMode(WrappingMode mode) { m_wrappingMode = mode; this->updateContainer(); } @@ -84,7 +84,7 @@ std::string SimpleTextArea::getText() { return m_text; } -void SimpleTextArea::setMaxLines(const size_t maxLines) { +void SimpleTextArea::setMaxLines(size_t maxLines) { m_maxLines = maxLines; this->updateContainer(); } @@ -93,7 +93,7 @@ size_t SimpleTextArea::getMaxLines() { return m_maxLines; } -void SimpleTextArea::setWidth(const float width) { +void SimpleTextArea::setWidth(float width) { m_artificialWidth = true; this->updateContainer(); @@ -105,7 +105,7 @@ float SimpleTextArea::getWidth() { return m_container->getContentSize().width; } -void SimpleTextArea::setScale(const float scale) { +void SimpleTextArea::setScale(float scale) { m_scale = scale; this->updateContainer(); } @@ -114,7 +114,7 @@ float SimpleTextArea::getScale() { return m_scale; } -void SimpleTextArea::setLinePadding(const float padding) { +void SimpleTextArea::setLinePadding(float padding) { m_linePadding = padding; this->updateContainer(); } @@ -135,7 +135,7 @@ float SimpleTextArea::getLineHeight() { return m_lineHeight; } -CCLabelBMFont* SimpleTextArea::createLabel(const std::string& text, const float top) { +CCLabelBMFont* SimpleTextArea::createLabel(const std::string& text, float top) { if (m_maxLines && m_lines.size() >= m_maxLines) { CCLabelBMFont* last = m_lines.at(m_maxLines - 1); const std::string& text = last->getString(); @@ -159,7 +159,7 @@ float SimpleTextArea::calculateOffset(CCLabelBMFont* label) { return m_linePadding + label->getContentSize().height * m_scale; } -void SimpleTextArea::charIteration(const std::function& overflowHandling) { +void SimpleTextArea::charIteration(const std::function& overflowHandling) { float top = 0; m_lines.clear(); CCLabelBMFont* line = this->createLabel("", top); @@ -208,7 +208,7 @@ void SimpleTextArea::updateLinesNoWrap() { } void SimpleTextArea::updateLinesWordWrap(bool spaceWrap) { - this->charIteration([this, spaceWrap](CCLabelBMFont* line, const char c, const float top) { + this->charIteration([this, spaceWrap](CCLabelBMFont* line, char c, float top) { const std::string_view delimiters(spaceWrap ? " " : " `~!@#$%^&*()-_=+[{}];:'\",<.>/?\\|"); if (delimiters.find(c) == std::string_view::npos) { @@ -228,7 +228,7 @@ void SimpleTextArea::updateLinesWordWrap(bool spaceWrap) { } void SimpleTextArea::updateLinesCutoffWrap() { - this->charIteration([this](CCLabelBMFont* line, const char c, const float top) { + this->charIteration([this](CCLabelBMFont* line, char c, float top) { const std::string& text = line->getString(); const char back = text.back(); const bool lastIsSpace = back == ' '; diff --git a/loader/src/utils/web.cpp b/loader/src/utils/web.cpp index 4f872b36..0f4a5246 100644 --- a/loader/src/utils/web.cpp +++ b/loader/src/utils/web.cpp @@ -221,7 +221,7 @@ WebRequest::WebRequest() : m_impl(std::make_shared()) {} WebRequest::~WebRequest() {} // Encodes a url param -std::string urlParamEncode(std::string_view const input) { +static std::string urlParamEncode(std::string_view input) { std::ostringstream ss; ss << std::hex << std::uppercase; for (char c : input) {