Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Performance: speed up Hash#except. [#382 state:resolved]

  • Loading branch information...
commit a797375c99efc88ee1438925cdc016305c66166c 1 parent a065144
@granth granth authored jeremy committed
Showing with 4 additions and 3 deletions.
  1. +4 −3 activesupport/lib/active_support/core_ext/hash/except.rb
View
7 activesupport/lib/active_support/core_ext/hash/except.rb
@@ -10,13 +10,14 @@ module Hash #:nodoc:
module Except
# Returns a new hash without the given keys.
def except(*keys)
- rejected = Set.new(respond_to?(:convert_key) ? keys.map { |key| convert_key(key) } : keys)
- reject { |key,| rejected.include?(key) }
+ clone.except!(*keys)
end
# Replaces the hash without only the given keys.
def except!(*keys)
- replace(except(*keys))
+ keys.map! { |key| convert_key(key) } if respond_to?(:convert_key)
+ keys.each { |key| delete(key) }
+ self
end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.