From 7568c7a101f8b371f7cbd6018450bf3e2cd72b59 Mon Sep 17 00:00:00 2001 From: David Taylor Date: Wed, 28 Apr 2021 17:27:18 +0100 Subject: [PATCH] PERF: Make stylesheet max_file_mtime calculation more efficient (#12876) Plugins always store their stylesheets under `/assets/stylesheets`, so we can make the glob pattern much more specific. In my local development environment, this increases the speed of `Stylesheet::Manager.max_file_mtime` from ~65ms to ~3ms (20x faster). This significantly improves stylesheet regeneration time, and the responsiveness of the theme admin UI. Note that this will have negligible effect in production, because in production the value of `max_file_mtime` is aggressively cached. --- lib/stylesheet/manager.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/stylesheet/manager.rb b/lib/stylesheet/manager.rb index 2d92ed8c5e2..91f449c06e3 100644 --- a/lib/stylesheet/manager.rb +++ b/lib/stylesheet/manager.rb @@ -208,7 +208,7 @@ class Stylesheet::Manager Discourse.plugins.map { |plugin| File.dirname(plugin.path) }.each do |path| globs << "#{path}/plugin.rb" - globs << "#{path}/**/*.*css" + globs << "#{path}/assets/stylesheets/**/*.*css" end globs.map do |pattern|