From f7c640e550724c499bce4be9d792248c5d5e850a Mon Sep 17 00:00:00 2001 From: WS64 Date: Thu, 18 Sep 2014 10:17:40 +0200 Subject: [PATCH] Code optimization --- frontend/docsettings.lua | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/frontend/docsettings.lua b/frontend/docsettings.lua index 1c3e7f204..a4a59001c 100644 --- a/frontend/docsettings.lua +++ b/frontend/docsettings.lua @@ -2,18 +2,7 @@ local lfs = require("libs/libkoreader-lfs") local DocSettings = {} function DocSettings:getHistoryPath(fullpath) - local i = #fullpath - 1 - -- search for last slash - while i > 0 do - if fullpath:sub(i,i) == "/" then - break - end - i = i - 1 - end - -- construct path to configuration file in history dir - local filename = fullpath:sub(i+1, -1) - local basename = fullpath:sub(1, i) - return "./history/["..basename:gsub("/","#").."] "..filename..".lua" + return "./history/[" .. fullpath:gsub("/","#"):gsub("(.*#)([^#]+)","%1] %2") .. ".lua" end function DocSettings:getPathFromHistory(hist_name)