mirror of
https://github.com/TangentFoxy/inspect.lua.git
synced 2025-07-28 02:52:18 +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:
@@ -45,10 +45,8 @@ local controlCharsTranslation = {
|
||||
["\r"] = "\\r", ["\t"] = "\\t", ["\v"] = "\\v"
|
||||
}
|
||||
|
||||
local function escapeChar(c) return controlCharsTranslation[c] end
|
||||
|
||||
local function escape(str)
|
||||
local result = str:gsub("\\", "\\\\"):gsub("(%c)", escapeChar)
|
||||
local result = str:gsub("\\", "\\\\"):gsub("(%c)", controlCharsTranslation)
|
||||
return result
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user