From 9d7fc5c1d44705d7a67eaf3fd8ea46f18eaa6b93 Mon Sep 17 00:00:00 2001 From: Tobias Witek Date: Sat, 18 Nov 2017 14:51:25 +0100 Subject: [PATCH] [core/themes] De-duplicate theme names List themes only once, even if they are present multiple times in different locations. (Yes, I know that list(set(result)) would do the same, but here, I'd like to not waste memory and be a bit faster). see #203 --- bumblebee/theme.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bumblebee/theme.py b/bumblebee/theme.py index a7c99cb..4224c0c 100644 --- a/bumblebee/theme.py +++ b/bumblebee/theme.py @@ -18,12 +18,14 @@ def theme_path(): ] def themes(): - result = [] + themes = {} for path in theme_path(): for filename in glob.iglob("{}/*.json".format(path)): if "test" not in filename: - result.append(os.path.basename(filename).replace(".json", "")) + themes[os.path.basename(filename).replace(".json", "")] = 1 + result = themes.keys() + result.sort() return result class Theme(object):