diff --git a/src/ui/widget/template-list.cpp b/src/ui/widget/template-list.cpp index f516e857507042fa64cb5923c2842796cc987c8e..240fe86158036d45fc5b1dfa6ffafb57b128075d 100644 --- a/src/ui/widget/template-list.cpp +++ b/src/ui/widget/template-list.cpp @@ -108,13 +108,20 @@ void TemplateList::init(Inkscape::Extension::TemplateShow mode) */ Glib::RefPtr TemplateList::icon_to_pixbuf(std::string const &path) { - // TODO: Add some caching here. - if (!path.empty()) { - Inkscape::svg_renderer renderer(path.c_str()); - return renderer.render(1.0); + // TODO: cache to filesystem. This function is a major bottleneck for startup time (ca. 1 second)! + // The current memory-based caching only catches the case where multiple templates share the same icon. + static std::map> cache; + if (path.empty()) { + Glib::RefPtr no_image; + return no_image; } - Glib::RefPtr no_image; - return no_image; + if (cache.contains(path)) { + return cache[path]; + } + Inkscape::svg_renderer renderer(path.c_str()); + auto result = renderer.render(1.0); + cache[path] = result; + return result; } /**