From b2217c6806ecf15a7c9c6ac3dec83c023d2ef343 Mon Sep 17 00:00:00 2001 From: mpeterv Date: Tue, 18 Nov 2014 19:42:53 +0300 Subject: [PATCH] Remove redundant `escapeChar` function `string.gsub` can accept a table as the third argument, no need to wrap it in a function. --- inspect.lua | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/inspect.lua b/inspect.lua index b7a5c24..b7107d4 100644 --- a/inspect.lua +++ b/inspect.lua @@ -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