Optimize menubar.icon_theme.lookup_icon: do not look twice
This commit is contained in:
parent
7afd8e3179
commit
7fa3dc97c8
|
@ -147,6 +147,7 @@ local directory_size_distance = function(self, subdirectory, icon_size)
|
||||||
end
|
end
|
||||||
|
|
||||||
local lookup_icon = function(self, icon_name, icon_size)
|
local lookup_icon = function(self, icon_name, icon_size)
|
||||||
|
local checked_already = {}
|
||||||
for _, subdir in ipairs(self.index_theme:get_subdirectories()) do
|
for _, subdir in ipairs(self.index_theme:get_subdirectories()) do
|
||||||
for _, basedir in ipairs(self.base_directories) do
|
for _, basedir in ipairs(self.base_directories) do
|
||||||
for _, ext in ipairs(self.extensions) do
|
for _, ext in ipairs(self.extensions) do
|
||||||
|
@ -156,6 +157,8 @@ local lookup_icon = function(self, icon_name, icon_size)
|
||||||
icon_name, ext)
|
icon_name, ext)
|
||||||
if awful.util.file_readable(filename) then
|
if awful.util.file_readable(filename) then
|
||||||
return filename
|
return filename
|
||||||
|
else
|
||||||
|
checked_already[filename] = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -170,6 +173,7 @@ local lookup_icon = function(self, icon_name, icon_size)
|
||||||
local filename = string.format("%s/%s/%s/%s.%s",
|
local filename = string.format("%s/%s/%s/%s.%s",
|
||||||
basedir, self.icon_theme_name, subdir,
|
basedir, self.icon_theme_name, subdir,
|
||||||
icon_name, ext)
|
icon_name, ext)
|
||||||
|
if not checked_already[filename] then
|
||||||
local dist = directory_size_distance(self, subdir, icon_size)
|
local dist = directory_size_distance(self, subdir, icon_size)
|
||||||
if awful.util.file_readable(filename) and dist < minimal_size then
|
if awful.util.file_readable(filename) and dist < minimal_size then
|
||||||
closest_filename = filename
|
closest_filename = filename
|
||||||
|
@ -178,11 +182,8 @@ local lookup_icon = function(self, icon_name, icon_size)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if closest_filename then
|
|
||||||
return closest_filename
|
|
||||||
end
|
end
|
||||||
|
return closest_filename
|
||||||
return nil
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local find_icon_path_helper -- Gets called recursively.
|
local find_icon_path_helper -- Gets called recursively.
|
||||||
|
|
Loading…
Reference in New Issue