[#35789] [Ruby 1.9 - Bug #407] (Open) String#<< — Shyouhei Urabe <redmine@...>

チケット #407 が報告されました。 (by Shyouhei Urabe)

13 messages 2008/08/06

[#35845] [Bug #437] test_strftime(TestTime) fails on Solaris — Shugo Maeda <redmine@...>

Bug #437: test_strftime(TestTime) fails on Solaris

24 messages 2008/08/13
[#35855] Re: [Bug #437] test_strftime(TestTime) fails on Solaris — "Shugo Maeda" <shugo@...> 2008/08/15

前田です。

[#35856] Re: [Bug #437] test_strftime(TestTime) fails on Solaris — SATOH Fumiyasu <fumiyas@...> 2008/08/15

さとうふみやす @ OSS テクノロジです。

[#35857] Re: [Bug #437] test_strftime(TestTime) fails on Solaris — Yukihiro Matsumoto <matz@...> 2008/08/15

まつもと ゆきひろです

[#35870] Re: [Bug #437] test_strftime(TestTime) fails on Solaris — "Shugo Maeda" <shugo@...> 2008/08/18

前田です。

[#35863] Refactoring of enumerating prime numbers — "Yugui (Yuki Sonoda)" <yugui@...>

Yuguiです。

20 messages 2008/08/16
[#35865] Re: Refactoring of enumerating prime numbers — keiju@... (keiju ISHITSUKA) 2008/08/17

けいじゅ@いしつかです.

[#35867] Re: Refactoring of enumerating prime numbers — "Yugui (Yuki Sonoda)" <yugui@...> 2008/08/17

Yuguiです。

[#35875] Re: Refactoring of enumerating prime numbers — keiju@... (keiju ISHITSUKA) 2008/08/19

けいじゅ@いしつかです.

[#35877] Re: Refactoring of enumerating prime numbers — Nobuyoshi Nakada <nobu@...> 2008/08/19

なかだです。

[#35882] Re: Refactoring of enumerating prime numbers — keiju@... (石塚圭樹) 2008/08/20

けいじゅ@いしつかです.

[#35904] [Feature:1.9] pack format 'm' based on RFC 4648 — "Yusuke ENDOH" <mame@...>

遠藤です。

14 messages 2008/08/21
[#36442] [Feature #471] pack format 'm' based on RFC 4648 — Yuki Sonoda <redmine@...> 2008/09/22

チケット #471 が更新されました。 (by Yuki Sonoda)

[#35906] %N for Time#strftime — "Shugo Maeda" <shugo@...>

前田です。

13 messages 2008/08/21

[#35986] 1.9と1.8で、delegateのインスタンスのクラス名の違う — Fujioka <fuj@...>

xibbarこと藤岡です。

17 messages 2008/08/26
[#35987] Re: 1.9と1.8で、delegateのインスタンスのクラス名の違う — Yukihiro Matsumoto <matz@...> 2008/08/26

まつもと ゆきひろです

[#35991] Re: 1.9と1.8で、delegateのインスタンスのクラス名の違う — keiju@... (石塚圭樹) 2008/08/26

けいじゅ@いしつかです.

[#35994] Re: 1.9と1.8で、delegateのインスタンスのクラス名の違う — Fujioka <fuj@...> 2008/08/27

藤岡です。

[#35998] Re: 1.9と1.8で、delegateのインスタンスのクラス名の違う — keiju@... (石塚圭樹) 2008/08/27

けいじゅ@いしつかです.

[#36066] Numeric#scalar? — Tadayoshi Funaba <tadf@...>

1.9 の Numeric#scalar? について、適当でないのでは (real? などのほうがい

24 messages 2008/08/31
[#36069] Re: Numeric#scalar? — Shin-ichiro HARA <sinara@...> 2008/08/31

原です。

[#36104] Re: Numeric#scalar? — Tadayoshi Funaba <tadf@...> 2008/09/02

> やはり、scalar? はずれているんじゃないかな。real? の方がいい

[#36122] Re: Numeric#scalar? — Shin-ichiro HARA <sinara@...> 2008/09/03

原です。

[#36133] Re: Numeric#scalar? — Tadayoshi Funaba <tadf@...> 2008/09/03

> ここで、scalar? を疑問視する理由を復習すると、たとえば、「複

[#36173] Re: Numeric#scalar? — Tadayoshi Funaba <tadf@...> 2008/09/05

1.9.1 までに時間がないので scalar? だけ何とかしたいと思っていましたが、

[#36183] Re: Numeric#scalar? — "Shugo Maeda" <shugo@...> 2008/09/06

前田です。

[#36186] Re: Numeric#scalar? — Shin-ichiro HARA <sinara@...> 2008/09/06

原です。

[ruby-dev:36015] Re: block parameter for Delagator

From: Yukihiro Matsumoto <matz@...>
Date: 2008-08-27 14:07:45 UTC
List: ruby-dev #36015
まつもと ゆきひろです

In message "Re: [ruby-dev:35988] Re: block parameter for Delagator"
    on Tue, 26 Aug 2008 23:34:37 +0900, "Yusuke ENDOH" <mame@tsg.ne.jp> writes:

|バグかどうかはわかりませんが直してみました。
|が、以下のコードが 3 倍遅くなりました。どんなもんでしょう。

TYPE(obj) == T_ARRAYという条件はduck typing的によくないと思
うので、直した方がよいとは思うのですが、確かに性能には影響が
ありますねえ。

増加したコストは主に

  * conver_typeに文字列で渡されたメソッド名のintern
  * T_ARRAYでなかった時のrespond_toでのチェック

なので、この辺の無駄を削ってみましたが、それでもまだまだ遅い
ですねえ。まあ、実際にはこのコストがそれほど問題になることは
ないとは思いますが。

diff --git a/object.c b/object.c
index fd15e87..dd71c1b 100644
--- a/object.c
+++ b/object.c
@@ -1960,12 +1960,36 @@ rb_mod_cvar_defined(VALUE obj, VALUE iv)
     return rb_cvar_defined(obj, id);
 }
 
+static struct conv_method_tbl {
+    const char *method;
+    ID id;
+} conv_method_names[] = {
+    {"to_int", 0},
+    {"to_ary", 0},
+    {"to_str", 0},
+    {"to_sym", 0},
+    {"to_hash", 0},
+    {"to_proc", 0},
+    {"to_io", 0},
+    {"to_a", 0},
+    {"to_s", 0},
+    {NULL, 0}
+};
+
 static VALUE
 convert_type(VALUE val, const char *tname, const char *method, int raise)
 {
-    ID m;
+    ID m = 0;
+    int i;
 
-    m = rb_intern(method);
+    for (i=0; conv_method_names[i].method; i++) {
+	if (conv_method_names[i].method[0] == method[0] &&
+	    strcmp(conv_method_names[i].method, method) == 0) {
+	    m = conv_method_names[i].id;
+	    break;
+	}
+    }
+    if (!m) m = rb_intern(method);
     if (!rb_respond_to(val, m)) {
 	if (raise) {
 	    rb_raise(rb_eTypeError, "can't convert %s into %s",
@@ -2427,6 +2451,8 @@ boot_defclass(const char *name, VALUE super)
 void
 Init_Object(void)
 {
+    int i;
+
 #undef rb_intern
 #define rb_intern(str) rb_intern_const(str)
 
@@ -2606,4 +2632,8 @@ Init_Object(void)
     id_match = rb_intern("=~");
     id_inspect = rb_intern("inspect");
     id_init_copy = rb_intern("initialize_copy");
+
+    for (i=0; conv_method_names[i].method; i++) {
+	conv_method_names[i].id = rb_intern(conv_method_names[i].method);
+    }
 }
diff --git a/vm_method.c b/vm_method.c
index 0254741..82ae5a4 100644
--- a/vm_method.c
+++ b/vm_method.c
@@ -292,8 +292,9 @@ rb_method_node(VALUE klass, ID id)
     struct cache_entry *ent;
 
     ent = cache + EXPR1(klass, id);
-    if (ent->mid == id && ent->klass == klass && ent->method) {
-	return ent->method;
+    if (ent->mid == id && ent->klass == klass) {
+	if (ent->method) return ent->method;
+	return 0;
     }
 
     return rb_get_method_body(klass, id, 0);
@@ -1067,9 +1068,13 @@ int
 rb_obj_respond_to(VALUE obj, ID id, int priv)
 {
     VALUE klass = CLASS_OF(obj);
+    NODE * node = rb_method_node(klass, id);
 
-    if (rb_method_basic_definition_p(klass, idRespond_to)) {
-	return rb_method_boundp(klass, id, !priv);
+    if (node && (node->nd_noex & NOEX_BASIC)) {
+	if (!priv && (node->nd_noex & NOEX_PRIVATE)) {
+	    return Qtrue;
+	}
+	return Qfalse;
     }
     else {
 	VALUE args[2];

In This Thread