Skip to content

Commit

Permalink
Fix small overhead in argument parser for strings (#3294)
Browse files Browse the repository at this point in the history
  • Loading branch information
TheNormalnij authored Jun 16, 2024
1 parent e3f9099 commit d20582d
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions Shared/mods/deathmatch/logic/lua/LuaBasic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,18 @@ namespace lua
template <>
std::string PopPrimitive<std::string>(lua_State* L, int& index)
{
uint uiLength = lua_strlen(L, index);
std::string outValue;
outValue.assign(lua_tostring(L, index++), uiLength);
size_t length;
const char* str = lua_tolstring(L, index++, &length);
std::string outValue(str, length);
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 d20582d

Please sign in to comment.