Permalink
Browse files

Use symbols instead of strings

ActiveSupport::Concern is used all over Rails
This PR will only create 3 new objects as keys are never recreated and
are not subject to garbage collection.

The strings were being uniquely created and garbage collected. I don't
have any performance numbers but this should be better than all of the
GC.
  • Loading branch information...
1 parent ebf2113 commit 748d3f38df5d32c5e1eb1d82c07b8abffbb44973 @bcardarella bcardarella committed Jun 11, 2013
Showing with 6 additions and 6 deletions.
  1. +6 −6 activesupport/lib/active_support/concern.rb
@@ -105,25 +105,25 @@ def initialize
end
def self.extended(base) #:nodoc:
- base.instance_variable_set("@_dependencies", [])
+ base.instance_variable_set(:@_dependencies, [])
end
def append_features(base)
- if base.instance_variable_defined?("@_dependencies")
- base.instance_variable_get("@_dependencies") << self
+ if base.instance_variable_defined?(:@_dependencies)
+ base.instance_variable_get(:@_dependencies) << self
return false
else
return false if base < self
@_dependencies.each { |dep| base.send(:include, dep) }
super
- base.extend const_get("ClassMethods") if const_defined?("ClassMethods")
- base.class_eval(&@_included_block) if instance_variable_defined?("@_included_block")
+ base.extend const_get(:ClassMethods) if const_defined?(:ClassMethods)
+ base.class_eval(&@_included_block) if instance_variable_defined?(:@_included_block)
end
end
def included(base = nil, &block)
if base.nil?
- raise MultipleIncludedBlocks if instance_variable_defined?("@_included_block")
+ raise MultipleIncludedBlocks if instance_variable_defined?(:@_included_block)
@_included_block = block
else

0 comments on commit 748d3f3

Please sign in to comment.