From 9eb28def57707b6467df17822f283d532d5dd913 Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Tue, 30 Jul 2024 12:17:27 +0100 Subject: [PATCH] Codechange: Return reference from GetNextParameterPointer. GetNextParameterPointer can no longer return nullptr, and the callers do not check for nullptr, so return a reference instead. --- src/strings.cpp | 6 +++--- src/strings_internal.h | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/strings.cpp b/src/strings.cpp index ac959f7ddd..f4ac15de96 100644 --- a/src/strings.cpp +++ b/src/strings.cpp @@ -76,9 +76,9 @@ void StringParameters::PrepareForNextRun() * Get the next parameter from our parameters. * This updates the offset, so the next time this is called the next parameter * will be read. - * @return The pointer to the next parameter. + * @return The next parameter. */ -StringParameter *StringParameters::GetNextParameterPointer() +const StringParameter &StringParameters::GetNextParameterReference() { assert(this->next_type == 0 || (SCC_CONTROL_START <= this->next_type && this->next_type <= SCC_CONTROL_END)); if (this->offset >= this->parameters.size()) { @@ -92,7 +92,7 @@ StringParameter *StringParameters::GetNextParameterPointer() } param.type = this->next_type; this->next_type = 0; - return ¶m; + return param; } diff --git a/src/strings_internal.h b/src/strings_internal.h index 3095e33107..1ef5a4a6a8 100644 --- a/src/strings_internal.h +++ b/src/strings_internal.h @@ -32,7 +32,7 @@ protected: parameters(parameters) {} - StringParameter *GetNextParameterPointer(); + const StringParameter &GetNextParameterReference(); public: /** @@ -92,8 +92,8 @@ public: template T GetNextParameter() { - auto ptr = GetNextParameterPointer(); - return static_cast(ptr->data); + const auto ¶m = GetNextParameterReference(); + return static_cast(param.data); } /** @@ -104,8 +104,8 @@ public: */ const char *GetNextParameterString() { - auto ptr = GetNextParameterPointer(); - return ptr->string != nullptr ? ptr->string->c_str() : nullptr; + const auto ¶m = GetNextParameterReference(); + return param.string != nullptr ? param.string->c_str() : nullptr; } /**