Merge pull request #10 from lioncash/cv

CVar: Remove redundant const return for toLiteral() and toWideLiteral()
This commit is contained in:
Phillip Stephens 2019-08-20 19:31:06 -07:00 committed by GitHub
commit bcfea9a09a
2 changed files with 8 additions and 6 deletions

View File

@ -70,8 +70,8 @@ public:
float toFloat(bool* isValid = nullptr) const; float toFloat(bool* isValid = nullptr) const;
bool toBoolean(bool* isValid = nullptr) const; bool toBoolean(bool* isValid = nullptr) const;
int toInteger(bool* isValid = nullptr) const; int toInteger(bool* isValid = nullptr) const;
const std::wstring toWideLiteral(bool* isValid = nullptr) const; std::wstring toWideLiteral(bool* isValid = nullptr) const;
const std::string toLiteral(bool* isValid = nullptr) const; std::string toLiteral(bool* isValid = nullptr) const;
bool fromVec4f(const atVec4f& val); bool fromVec4f(const atVec4f& val);
bool fromFloat(float val); bool fromFloat(float val);

View File

@ -191,23 +191,25 @@ int CVar::toInteger(bool* isValid) const {
return strtol(m_value.c_str(), nullptr, 0); return strtol(m_value.c_str(), nullptr, 0);
} }
const std::string CVar::toLiteral(bool* isValid) const { std::string CVar::toLiteral(bool* isValid) const {
if (m_type != EType::Literal && (com_developer && com_developer->toBoolean())) { if (m_type != EType::Literal && (com_developer && com_developer->toBoolean())) {
if (isValid != nullptr) if (isValid != nullptr)
*isValid = false; *isValid = false;
} else if (isValid != nullptr) } else if (isValid != nullptr) {
*isValid = true; *isValid = true;
}
// Even if it's not a literal, it's still safe to return // Even if it's not a literal, it's still safe to return
return m_value; return m_value;
} }
const std::wstring CVar::toWideLiteral(bool* isValid) const { std::wstring CVar::toWideLiteral(bool* isValid) const {
if (m_type != EType::Literal && (com_developer && com_developer->toBoolean())) { if (m_type != EType::Literal && (com_developer && com_developer->toBoolean())) {
if (isValid != nullptr) if (isValid != nullptr)
*isValid = false; *isValid = false;
} else if (isValid != nullptr) } else if (isValid != nullptr) {
*isValid = true; *isValid = true;
}
// Even if it's not a literal, it's still safe to return // Even if it's not a literal, it's still safe to return
return hecl::UTF8ToWide(m_value); return hecl::UTF8ToWide(m_value);