Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

No need to build a Set since we're iterating instead of checking for …

…inclusion now
  • Loading branch information...
commit 67e4f16fc5303ae35bdfe9ef4ef016127751ce35 1 parent 6367973
@jeremy jeremy authored
Showing with 2 additions and 4 deletions.
  1. +2 −4 activesupport/lib/active_support/core_ext/hash/slice.rb
View
6 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 Hash #: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
Please sign in to comment.
Something went wrong with that request. Please try again.