diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2008-06-07 18:06:45 -0700 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2008-06-07 18:06:45 -0700 |
commit | 67e4f16fc5303ae35bdfe9ef4ef016127751ce35 (patch) | |
tree | f07245dd9f3d0f9662c7e2270a8a413a1259cf83 /activesupport | |
parent | 63679733d8217b69e242a00083abfc4cd8a9dca0 (diff) | |
download | rails-67e4f16fc5303ae35bdfe9ef4ef016127751ce35.tar.gz rails-67e4f16fc5303ae35bdfe9ef4ef016127751ce35.tar.bz2 rails-67e4f16fc5303ae35bdfe9ef4ef016127751ce35.zip |
No need to build a Set since we're iterating instead of checking for inclusion now
Diffstat (limited to 'activesupport')
-rw-r--r-- | activesupport/lib/active_support/core_ext/hash/slice.rb | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/activesupport/lib/active_support/core_ext/hash/slice.rb b/activesupport/lib/active_support/core_ext/hash/slice.rb index 1b2c8f63e3..be4dec6e53 100644 --- a/activesupport/lib/active_support/core_ext/hash/slice.rb +++ b/activesupport/lib/active_support/core_ext/hash/slice.rb @@ -1,5 +1,3 @@ -require 'set' - module ActiveSupport #:nodoc: module CoreExtensions #:nodoc: module Hash #:nodoc: @@ -14,9 +12,9 @@ module ActiveSupport #:nodoc: module Slice # Returns a new hash with only the given keys. def slice(*keys) - allowed = Set.new(respond_to?(:convert_key) ? keys.map { |key| convert_key(key) } : keys) + keys = keys.map! { |key| convert_key(key) } if respond_to?(:convert_key) hash = {} - allowed.each { |k| hash[k] = self[k] if has_key?(k) } + keys.each { |k| hash[k] = self[k] if has_key?(k) } hash end |