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

ruby-changes:34782

From: nobu <ko1@a...>
Date: Fri, 18 Jul 2014 22:17:01 +0900 (JST)
Subject: [ruby-changes:34782] nobu:r46865 (trunk): revert r46859 and r46860

nobu	2014-07-18 22:16:37 +0900 (Fri, 18 Jul 2014)

  New Revision: 46865

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

  Log:
    revert r46859 and r46860
    
    revert "enum.c: optimize any? object allocations for Array and Hash"

  Modified files:
    trunk/ChangeLog
    trunk/common.mk
    trunk/enum.c
    trunk/vm.c
    trunk/vm_core.h
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 46864)
+++ ChangeLog	(revision 46865)
@@ -18,12 +18,6 @@ Fri Jul 18 17:41:54 2014  GoGo tanaka  < https://github.com/ruby/ruby/blob/trunk/ChangeLog#L18
 	* test/matrix/test_matrix.rb: Add tests for Matrix class.
 	  [Feature #10057][ruby-core:63809]
 
-Fri Jul 18 11:10:53 2014  Scott Francis  <scott.francis@s...>
-
-	* enum.c (enum_any): optimize object allocations for Array and
-	  Hash when `each` is not redefined, always false if empty and the
-	  case without a block.  [fix GH-671]
-
 Fri Jul 18 10:14:42 2014  SHIBATA Hiroshi  <shibata.hiroshi@g...>
 
 	* lib/fileutils.rb: added missing options of FileUtils.touch by @Domon.
Index: vm_core.h
===================================================================
--- vm_core.h	(revision 46864)
+++ vm_core.h	(revision 46865)
@@ -341,7 +341,6 @@ enum ruby_basic_operators { https://github.com/ruby/ruby/blob/trunk/vm_core.h#L341
     BOP_NEQ,
     BOP_MATCH,
     BOP_FREEZE,
-    BOP_EACH,
 
     BOP_LAST_
 };
Index: enum.c
===================================================================
--- enum.c	(revision 46864)
+++ enum.c	(revision 46865)
@@ -14,7 +14,6 @@ https://github.com/ruby/ruby/blob/trunk/enum.c#L14
 #include "node.h"
 #include "id.h"
 #include "internal.h"
-#include "vm_core.h"
 
 VALUE rb_f_send(int argc, VALUE *argv, VALUE recv);
 
@@ -1024,11 +1023,6 @@ name##_iter_i(RB_BLOCK_CALL_FUNC_ARGLIST https://github.com/ruby/ruby/blob/trunk/enum.c#L1023
 static VALUE \
 enum_##name##_func(VALUE result, NODE *memo)
 
-#define ARY_OPTIMIZABLE_EACH(obj) \
-    (RBASIC_CLASS(obj) == rb_cArray && BASIC_OP_UNREDEFINED_P(BOP_EACH, ARRAY_REDEFINED_OP_FLAG))
-#define HASH_OPTIMIZABLE_EACH(obj) \
-    (RBASIC_CLASS(obj) == rb_cHash && BASIC_OP_UNREDEFINED_P(BOP_EACH, HASH_REDEFINED_OP_FLAG))
-
 DEFINE_ENUMFUNCS(all)
 {
     if (!RTEST(result)) {
@@ -1092,34 +1086,7 @@ DEFINE_ENUMFUNCS(any) https://github.com/ruby/ruby/blob/trunk/enum.c#L1086
 static VALUE
 enum_any(VALUE obj)
 {
-    NODE *memo;
-
-    if (!SPECIAL_CONST_P(obj)) {
-	switch (BUILTIN_TYPE(obj)) {
-	  case T_ARRAY:
-	    if (ARY_OPTIMIZABLE_EACH(obj)) {
-		long i, len = RARRAY_LEN(obj);
-		if (!len) return Qfalse;
-		if (!rb_block_given_p()) {
-		    const VALUE *ptr = RARRAY_CONST_PTR(obj);
-		    for (i = 0; i < len; ++i) if (RTEST(ptr[i])) return Qtrue;
-		    return Qfalse;
-		}
-	    }
-	    break;
-	  case T_HASH:
-	    if (HASH_OPTIMIZABLE_EACH(obj)) {
-		if (RHASH_EMPTY_P(obj)) return Qfalse;
-		if (!rb_block_given_p()) {
-		    /* yields pairs, never false */
-		    return Qtrue;
-		}
-	    }
-	    break;
-	}
-    }
-
-    memo = NEW_MEMO(Qfalse, 0, 0);
+    NODE *memo = NEW_MEMO(Qfalse, 0, 0);
     rb_block_call(obj, id_each, 0, 0, ENUMFUNC(any), (VALUE)memo);
     return memo->u1.value;
 }
Index: common.mk
===================================================================
--- common.mk	(revision 46864)
+++ common.mk	(revision 46865)
@@ -689,7 +689,7 @@ encoding.$(OBJEXT): {$(VPATH)}encoding.c https://github.com/ruby/ruby/blob/trunk/common.mk#L689
   $(ENCODING_H_INCLUDES) {$(VPATH)}regenc.h {$(VPATH)}util.h \
   {$(VPATH)}internal.h
 enum.$(OBJEXT): {$(VPATH)}enum.c $(RUBY_H_INCLUDES) {$(VPATH)}node.h \
-  {$(VPATH)}util.h {$(VPATH)}id.h {$(VPATH)}internal.h $(VM_CORE_H_INCLUDES)
+  {$(VPATH)}util.h {$(VPATH)}id.h {$(VPATH)}internal.h
 enumerator.$(OBJEXT): {$(VPATH)}enumerator.c $(RUBY_H_INCLUDES) \
   {$(VPATH)}internal.h {$(VPATH)}node.h
 error.$(OBJEXT): {$(VPATH)}error.c {$(VPATH)}known_errors.inc \
Index: vm.c
===================================================================
--- vm.c	(revision 46864)
+++ vm.c	(revision 46865)
@@ -1236,7 +1236,6 @@ vm_init_redefined_flag(void) https://github.com/ruby/ruby/blob/trunk/vm.c#L1236
     OP(Succ, SUCC), (C(Fixnum), C(String), C(Time));
     OP(EqTilde, MATCH), (C(Regexp), C(String));
     OP(Freeze, FREEZE), (C(String));
-    OP(Each, EACH), (C(Array), C(Hash));
 #undef C
 #undef OP
 }

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

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