[前][次][番号順一覧][スレッド一覧]

ruby-changes:28805

From: knu <ko1@a...>
Date: Mon, 20 May 2013 22:28:45 +0900 (JST)
Subject: [ruby-changes:28805] knu:r40857 (trunk): * lib/set.rb (Set#delete_if, Set#keep_if): Avoid blockless call of

knu	2013-05-20 22:28:32 +0900 (Mon, 20 May 2013)

  New Revision: 40857

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=40857

  Log:
    * 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.

  Modified files:
    trunk/ChangeLog
    trunk/lib/set.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 40856)
+++ ChangeLog	(revision 40857)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Mon May 20 22:24:45 2013  Akinori MUSHA  <knu@i...>
+
+	* 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@z...>
 
 	* lib/e2mmap.rb: Format of E2MM documentation
Index: lib/set.rb
===================================================================
--- lib/set.rb	(revision 40856)
+++ lib/set.rb	(revision 40857)
@@ -1,7 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/lib/set.rb#L1
 #--
 # set.rb - defines the Set class
 #++
-# Copyright (c) 2002-2008 Akinori MUSHA <knu@i...>
+# Copyright (c) 2002-2013 Akinori MUSHA <knu@i...>
 #
 # Documentation by Akinori MUSHA and Gavin Sinclair.
 #
@@ -274,7 +274,7 @@ class Set https://github.com/ruby/ruby/blob/trunk/lib/set.rb#L274
     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 https://github.com/ruby/ruby/blob/trunk/lib/set.rb#L284
     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
 

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]