mirror of
https://github.com/kikito/inspect.lua.git
synced 2024-12-15 14:34:21 +00:00
Remove redundant escapeChar
function
`string.gsub` can accept a table as the third argument, no need to wrap it in a function.
This commit is contained in:
parent
54d2c28c7a
commit
b2217c6806
@ -45,10 +45,8 @@ local controlCharsTranslation = {
|
|||||||
["\r"] = "\\r", ["\t"] = "\\t", ["\v"] = "\\v"
|
["\r"] = "\\r", ["\t"] = "\\t", ["\v"] = "\\v"
|
||||||
}
|
}
|
||||||
|
|
||||||
local function escapeChar(c) return controlCharsTranslation[c] end
|
|
||||||
|
|
||||||
local function escape(str)
|
local function escape(str)
|
||||||
local result = str:gsub("\\", "\\\\"):gsub("(%c)", escapeChar)
|
local result = str:gsub("\\", "\\\\"):gsub("(%c)", controlCharsTranslation)
|
||||||
return result
|
return result
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user