From ab6963043df202bde77d67dfabff41cc3e7c11c8 Mon Sep 17 00:00:00 2001 From: matz Date: Tue, 16 Mar 2004 23:03:17 +0000 Subject: [PATCH] * error.c (exc_initialize): calling 'to_str' each time just for type checking is too heavy. [ruby-core:02661] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5965 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ error.c | 7 ++----- sample/test.rb | 8 +++++++- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index eb5032951c..eef6f107b3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -14,6 +14,11 @@ Tue Mar 16 11:14:17 Hirokazu Yamamoto * dir.c (fnmatch): File.fnmatch('**/.boo', '.foo/.boo', File::FNM_PATHNAME) should return false because of leading period. +Mon Mar 15 17:01:07 2004 Yukihiro Matsumoto + + * error.c (exc_initialize): calling 'to_str' each time just for + type checking is too heavy. [ruby-core:02661] + Mon Mar 15 10:14:51 2004 GOTOU Yuuzou * ext/openssl/lib/openssl/ssl.rb (OpenSSL::SSL::SocketForwarder): diff --git a/error.c b/error.c index c0999f84c9..efa43f38ae 100644 --- a/error.c +++ b/error.c @@ -327,7 +327,7 @@ rb_exc_new3(etype, str) VALUE etype, str; { StringValue(str); - return rb_exc_new(etype, RSTRING(str)->ptr, RSTRING(str)->len); + return rb_funcall(etype, rb_intern("new"), 1, str); } /* @@ -346,10 +346,7 @@ exc_initialize(argc, argv, exc) { VALUE arg; - if (rb_scan_args(argc, argv, "01", &arg) == 1) { - VALUE mesg = arg; - StringValue(mesg); /* ensure mesg can be converted to String */ - } + rb_scan_args(argc, argv, "01", &arg); rb_iv_set(exc, "mesg", arg); rb_iv_set(exc, "bt", Qnil); diff --git a/sample/test.rb b/sample/test.rb index 7e58cd5362..d61b1e7098 100644 --- a/sample/test.rb +++ b/sample/test.rb @@ -1264,6 +1264,12 @@ def test_b14 end test_ok(test_b14() == 144) +def test_b15 + [0].each {|c| yield 1 } + 156 +end +test_ok(test_b15{|e| break 155 } == 155) + def marity_test(m) method = method(m) test_ok(method.arity == method.to_proc.arity, 2) @@ -1992,7 +1998,7 @@ module Olympians @@rule ="Zeus" def ruler3 @@rule - end + end end class Titans < Gods