mirror of
https://github.com/1bardesign/batteries.git
synced 2024-11-29 16:24:35 +00:00
[modified] stringx.starts_with to not generate garbage
This commit is contained in:
parent
dfd1a1c69f
commit
290b39236c
11
stringx.lua
11
stringx.lua
@ -280,8 +280,15 @@ function stringx.apply_template(s, sub)
|
||||
return r
|
||||
end
|
||||
|
||||
function stringx.starts_with(s, start)
|
||||
return s:sub(1, #start) == start
|
||||
--check if a given string starts with another
|
||||
--(without garbage)
|
||||
function stringx.starts_with(s, prefix)
|
||||
for i = 1, #prefix do
|
||||
if s:byte(i) ~= prefix:byte(i) then
|
||||
return false
|
||||
end
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
return stringx
|
||||
|
Loading…
Reference in New Issue
Block a user