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

ruby-changes:66957

From: Koichi <ko1@a...>
Date: Thu, 29 Jul 2021 00:56:59 +0900 (JST)
Subject: [ruby-changes:66957] fa0279d947 (master): should not share same `def` for specialized method

https://git.ruby-lang.org/ruby.git/commit/?id=fa0279d947

From fa0279d947c3962c3f8c32852278d3ebb964cb19 Mon Sep 17 00:00:00 2001
From: Koichi Sasada <ko1@a...>
Date: Wed, 28 Jul 2021 13:40:30 +0900
Subject: should not share same `def` for specialized method

Because the key of redefine table is `def`, `def` should be
unique for each optimized method (`alias` is not allowed).
---
 array.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/array.c b/array.c
index 3cb57a0..36f712b 100644
--- a/array.c
+++ b/array.c
@@ -8384,7 +8384,7 @@ Init_Array(void) https://github.com/ruby/ruby/blob/trunk/array.c#L8384
     rb_define_method(rb_cArray, "each_index", rb_ary_each_index, 0);
     rb_define_method(rb_cArray, "reverse_each", rb_ary_reverse_each, 0);
     rb_define_method(rb_cArray, "length", rb_ary_length, 0);
-    rb_define_alias(rb_cArray,  "size", "length");
+    rb_define_method(rb_cArray, "size", rb_ary_length, 0);
     rb_define_method(rb_cArray, "empty?", rb_ary_empty_p, 0);
     rb_define_method(rb_cArray, "find_index", rb_ary_index, -1);
     rb_define_method(rb_cArray, "index", rb_ary_index, -1);
-- 
cgit v1.1


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

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