Skip to content

Commit

Permalink
luci-mod-freifunk: reduce usage of string.gsub()
Browse files Browse the repository at this point in the history
rearrange the code to not use gsub() two times.
Calling one time gsub and concat a string will be faster then using gsub() two times.

Signed-off-by: Sven Roederer <freifunk@it-solutions.geroedel.de>
  • Loading branch information
SvenRoederer committed Feb 16, 2019
1 parent 71fd445 commit d1e6af6
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ community.rmempty = false

local profile
for profile in fs.glob(profiles) do
local name = uci:get_first(string.gsub(profile, "/etc/config/", ""), "community", "name") or "?"
community:value(string.gsub(profile, "/etc/config/profile_", ""), name)
profile = string.gsub(profile, "/etc/config/profile_", "")
local name = uci:get_first("profile_" .. profile, "community", "name") or "?"
community:value(profile, name)
end


Expand Down

0 comments on commit d1e6af6

Please sign in to comment.