From 60e2fa5e955ce819c90f2081320554b5ed0ee83c Mon Sep 17 00:00:00 2001 From: Lachlan Sylvester Date: Tue, 28 Jul 2015 15:13:07 +1000 Subject: refactor channel look up to use a hash instead of an array and reduce the number of calls to safe_constantize because it can be slow --- lib/action_cable/server/base.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/action_cable/server') diff --git a/lib/action_cable/server/base.rb b/lib/action_cable/server/base.rb index b09fbf6da4..43849928b9 100644 --- a/lib/action_cable/server/base.rb +++ b/lib/action_cable/server/base.rb @@ -36,11 +36,11 @@ module ActionCable @worker_pool ||= ActionCable::Server::Worker.pool(size: config.worker_pool_size) end - # Requires and returns an array of all the channel class constants in this application. + # Requires and returns an hash of all the channel class constants keyed by name. def channel_classes @channel_classes ||= begin config.channel_paths.each { |channel_path| require channel_path } - config.channel_class_names.collect { |name| name.constantize } + config.channel_class_names.each_with_object({}) { |name, hash| hash[name] = name.constantize } end end -- cgit v1.2.3