summaryrefslogtreecommitdiff
path: root/lib/set.rb
diff options
context:
space:
mode:
authorknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-05-18 17:48:18 +0000
committerknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-05-18 17:48:18 +0000
commit2849ee5d18360f26b55643a2643a1c597376865d (patch)
tree3e6b37ebb7b4576b78d4faf34d9e0f99ba006bb9 /lib/set.rb
parent041224017c5a865ad0ea0d360bce1709b39d2255 (diff)
* lib/set.rb (Set#delete_if, Set#keep_if): Make Set#delete_if and
Set#keep_if more space and time efficient by avoiding to_a. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40819 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/set.rb')
-rw-r--r--lib/set.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/set.rb b/lib/set.rb
index b378253..4f925e3 100644
--- a/lib/set.rb
+++ b/lib/set.rb
@@ -272,7 +272,7 @@ class Set
# true, and returns self.
def delete_if
block_given? or return enum_for(__method__)
- to_a.each { |o| @hash.delete(o) if yield(o) }
+ select(&proc).each(&@hash.method(:delete))
self
end
@@ -280,7 +280,7 @@ class Set
# false, and returns self.
def keep_if
block_given? or return enum_for(__method__)
- to_a.each { |o| @hash.delete(o) unless yield(o) }
+ reject(&proc).each(&@hash.method(:delete))
self
end