Use string.find only in common.home_encode
Should be slightly more efficient.
This commit is contained in:
parent
d8244120e9
commit
d63afe02ed
|
@ -204,10 +204,10 @@ end
|
||||||
|
|
||||||
|
|
||||||
function common.home_encode(text)
|
function common.home_encode(text)
|
||||||
if HOME then
|
if HOME and string.find(text, HOME, 1, true) == 1 then
|
||||||
local n = #HOME
|
local dir_pos = #HOME + 1
|
||||||
if text:sub(1, n) == HOME and text:sub(n + 1, n + 1):match("[/\\\\]") then
|
if string.find(text, PATHSEP, dir_pos, true) == dir_pos then
|
||||||
return "~" .. text:sub(n + 1)
|
return "~" .. text:sub(dir_pos)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return text
|
return text
|
||||||
|
|
Loading…
Reference in New Issue