mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
PERF: Reduce N+1s on theme admin page
This commit is contained in:
@@ -142,13 +142,15 @@ class ColorScheme < ActiveRecord::Base
|
||||
@mutex = Mutex.new
|
||||
|
||||
def self.base_colors
|
||||
return @base_colors if @base_colors
|
||||
@mutex.synchronize do
|
||||
return @base_colors if @base_colors
|
||||
@base_colors = {}
|
||||
base_colors = {}
|
||||
File.readlines(BASE_COLORS_FILE).each do |line|
|
||||
matches = /\$([\w]+):\s*#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})(?:[;]|\s)/.match(line.strip)
|
||||
@base_colors[matches[1]] = matches[2] if matches
|
||||
base_colors[matches[1]] = matches[2] if matches
|
||||
end
|
||||
@base_colors = base_colors
|
||||
end
|
||||
@base_colors
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user