Skip to content

Commit

Permalink
Fix small overhead in argument parser for strings
Browse files Browse the repository at this point in the history
  • Loading branch information
TheNormalnij committed Jan 16, 2024
1 parent 478fd54 commit a0e562e
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions Shared/mods/deathmatch/logic/lua/LuaBasic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,19 @@ namespace lua
template <>
std::string PopPrimitive<std::string>(lua_State* L, int& index)
{
uint uiLength = lua_strlen(L, index);
size_t uiLength;
const char* str = lua_tolstring(L, index++, &uiLength);
std::string outValue;
outValue.assign(lua_tostring(L, index++), uiLength);
outValue.assign(str, uiLength);
return outValue;
}

template <>
std::string_view PopPrimitive<std::string_view>(lua_State* L, int& index)
{
uint uiLength = lua_strlen(L, index);
std::string_view outValue(lua_tostring(L, index++), uiLength);
size_t uiLength;
const char* str = lua_tolstring(L, index++, &uiLength);
std::string_view outValue(str, uiLength);
return outValue;
}

Expand Down

0 comments on commit a0e562e

Please sign in to comment.