1
0
mirror of https://github.com/OpenTTD/OpenTTD synced 2026-01-22 03:42:41 +01:00

Codechange: use std::optional<std::string_view> to make the intent of function clearer

This commit is contained in:
Rubidium
2025-05-03 17:05:13 +02:00
committed by rubidium42
parent ead3b96883
commit 0bc773215e
10 changed files with 33 additions and 35 deletions

View File

@@ -411,8 +411,11 @@ bool Squirrel::CallStringMethod(HSQOBJECT instance, std::string_view method_name
{
HSQOBJECT ret;
if (!this->CallMethod(instance, method_name, &ret, suspend)) return false;
if (ret._type != OT_STRING) return false;
*res = StrMakeValid(ObjectToString(&ret));
auto str = ObjectToString(&ret);
if (!str.has_value()) return false;
*res = StrMakeValid(*str);
return true;
}