Codechange: use std::string_view for sq_getstring

This commit is contained in:
Rubidium
2025-05-03 14:24:28 +02:00
committed by rubidium42
parent f4f05dea33
commit 278aee2c19
12 changed files with 74 additions and 73 deletions
+6 -6
View File
@@ -45,10 +45,10 @@ bool ScriptAdminMakeJSON(nlohmann::json &json, HSQUIRRELVM vm, SQInteger index,
}
case OT_STRING: {
const SQChar *buf;
sq_getstring(vm, index, &buf);
std::string_view view;
sq_getstring(vm, index, view);
json = std::string(buf);
json = view;
return true;
}
@@ -78,9 +78,9 @@ bool ScriptAdminMakeJSON(nlohmann::json &json, HSQUIRRELVM vm, SQInteger index,
sq_pushnull(vm);
while (SQ_SUCCEEDED(sq_next(vm, index - 1))) {
sq_tostring(vm, -2);
const SQChar *buf;
sq_getstring(vm, -1, &buf);
std::string key = std::string(buf);
std::string_view view;
sq_getstring(vm, -1, view);
std::string key{view};
sq_pop(vm, 1);
nlohmann::json value;