1
0
Fork 0

Codechange: Return reference from GetNextParameterPointer.

GetNextParameterPointer can no longer return nullptr, and the callers do not check for nullptr, so return a reference instead.
pull/12718/head
Peter Nelson 2024-07-30 12:17:27 +01:00 committed by Peter Nelson
parent 59b18560d4
commit 9eb28def57
2 changed files with 8 additions and 8 deletions

View File

@ -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 &param;
return param;
}

View File

@ -32,7 +32,7 @@ protected:
parameters(parameters)
{}
StringParameter *GetNextParameterPointer();
const StringParameter &GetNextParameterReference();
public:
/**
@ -92,8 +92,8 @@ public:
template <typename T>
T GetNextParameter()
{
auto ptr = GetNextParameterPointer();
return static_cast<T>(ptr->data);
const auto &param = GetNextParameterReference();
return static_cast<T>(param.data);
}
/**
@ -104,8 +104,8 @@ public:
*/
const char *GetNextParameterString()
{
auto ptr = GetNextParameterPointer();
return ptr->string != nullptr ? ptr->string->c_str() : nullptr;
const auto &param = GetNextParameterReference();
return param.string != nullptr ? param.string->c_str() : nullptr;
}
/**