Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions lua/wire/wireshared.lua
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,12 @@ function string.GetNormalizedFilepath( path ) -- luacheck: ignore
return table.concat(tbl, "/")
end

-- Cheaper string.Trim* functions
function WireLib.Trim(line)
-- Cheaper string.Trim* functions (when pattern is not used)
function WireLib.Trim(line, char)
if char then
return string.Trim(line, char)
end

local length = #line
local first

Expand Down Expand Up @@ -109,7 +113,11 @@ function WireLib.Trim(line)
return string_sub(line, first, last)
end

function WireLib.TrimLeft(line)
function WireLib.TrimLeft(line, char)
if char then
return string.TrimLeft(line, char)
end

for i = 1, #line do
local b = string_byte(line, i)

Expand All @@ -121,7 +129,11 @@ function WireLib.TrimLeft(line)
return ""
end

function WireLib.TrimRight(line)
function WireLib.TrimRight(line, char)
if char then
return string.TrimRight(line, char)
end

for i = #line, 1, -1 do
local b = string_byte(line, i)

Expand Down
Loading