diff options
author | knu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-05-20 13:28:32 +0000 |
---|---|---|
committer | knu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-05-20 13:28:32 +0000 |
commit | dcb4ceeac68e32be46016930f0dc82b18e4694e6 (patch) | |
tree | 34b6097966b5cf85bfe1991fd10b52b6bae05cfb | |
parent | b416c661e80b917fd316c7d758d1b60c0a638991 (diff) | |
download | ruby-dcb4ceeac68e32be46016930f0dc82b18e4694e6.tar.gz |
* lib/set.rb (Set#delete_if, Set#keep_if): Avoid blockless call of
proc, which is not portable to JRuby. Replace &method() with
faster and simpler literal blocks while at it.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40857 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | lib/set.rb | 6 |
2 files changed, 9 insertions, 3 deletions
@@ -1,3 +1,9 @@ +Mon May 20 22:24:45 2013 Akinori MUSHA <knu@iDaemons.org> + + * lib/set.rb (Set#delete_if, Set#keep_if): Avoid blockless call of + proc, which is not portable to JRuby. Replace &method() with + faster and simpler literal blocks while at it. + Mon May 20 22:00:31 2013 Zachary Scott <zachary@zacharyscott.net> * lib/e2mmap.rb: Format of E2MM documentation diff --git a/lib/set.rb b/lib/set.rb index 4668b4e24a..cc7542f223 100644 --- a/lib/set.rb +++ b/lib/set.rb @@ -1,7 +1,7 @@ #-- # set.rb - defines the Set class #++ -# Copyright (c) 2002-2008 Akinori MUSHA <knu@iDaemons.org> +# Copyright (c) 2002-2013 Akinori MUSHA <knu@iDaemons.org> # # Documentation by Akinori MUSHA and Gavin Sinclair. # @@ -274,7 +274,7 @@ class Set block_given? or return enum_for(__method__) # @hash.delete_if should be faster, but using it breaks the order # of enumeration in subclasses. - select(&proc).each(&@hash.method(:delete)) + select { |o| yield o }.each { |o| @hash.delete(o) } self end @@ -284,7 +284,7 @@ class Set block_given? or return enum_for(__method__) # @hash.keep_if should be faster, but using it breaks the order of # enumeration in subclasses. - reject(&proc).each(&@hash.method(:delete)) + reject { |o| yield o }.each { |o| @hash.delete(o) } self end |