From 67e4f16fc5303ae35bdfe9ef4ef016127751ce35 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Sat, 7 Jun 2008 18:06:45 -0700 Subject: No need to build a Set since we're iterating instead of checking for inclusion now --- activesupport/lib/active_support/core_ext/hash/slice.rb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'activesupport/lib/active_support/core_ext/hash/slice.rb') 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 -- cgit v1.2.3