1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* lib/set.rb (Set#replace): Apply a bit of optimization.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29434 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
knu 2010-10-10 09:45:36 +00:00
parent 3ec721b9c2
commit 72ef219804
2 changed files with 6 additions and 2 deletions

View file

@ -1,3 +1,7 @@
Sun Oct 10 18:42:23 2010 Akinori MUSHA <knu@iDaemons.org>
* lib/set.rb (Set#replace): Apply a bit of optimization.
Sun Oct 10 10:20:07 2010 Nobuyoshi Nakada <nobu@ruby-lang.org> Sun Oct 10 10:20:07 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
* configure.in (RUBY_MINGW32): canonicalize as like mswin version. * configure.in (RUBY_MINGW32): canonicalize as like mswin version.

4
lib/set.rb Normal file → Executable file
View file

@ -130,8 +130,8 @@ class Set
# Replaces the contents of the set with the contents of the given # Replaces the contents of the set with the contents of the given
# enumerable object and returns self. # enumerable object and returns self.
def replace(enum) def replace(enum)
if enum.class == self.class if enum.instance_of?(self.class)
@hash.replace(enum.instance_eval { @hash }) @hash.replace(enum.instance_variable_get(:@hash))
else else
clear clear
merge(enum) merge(enum)