Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix small overhead in argument parser for strings
Browse files Browse the repository at this point in the history
TheNormalnij committed Jan 16, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
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
@@ -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;
}

0 comments on commit a0e562e

Please sign in to comment.