summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog7
-rw-r--r--eval.c37
-rw-r--r--range.c11
3 files changed, 28 insertions, 27 deletions
diff --git a/ChangeLog b/ChangeLog
index 965abe4db9..a51410fd69 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Mon Aug 15 00:38:51 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * eval.c (rb_rescue2): reduce PUSH_TAG() as well as NODE_RESCUE.
+ [ruby-dev:26800]
+
+ * range.c (range_check, range_init): reduce uselse exceptions.
+
Sat Aug 13 18:51:26 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* eval.c (rb_block_pass): distinguish current block from others.
diff --git a/eval.c b/eval.c
index de8c05ef9b..08773c6fdf 100644
--- a/eval.c
+++ b/eval.c
@@ -5241,17 +5241,23 @@ rb_rescue2(b_proc, data1, r_proc, data2, va_alist)
int state;
volatile VALUE result;
volatile VALUE e_info = ruby_errinfo;
+ volatile int handle;
+ VALUE eclass;
va_list args;
PUSH_TAG(PROT_NONE);
- if ((state = EXEC_TAG()) == 0) {
- retry_entry:
+ switch (state = EXEC_TAG()) {
+ case TAG_RETRY:
+ if (!handle) break;
+ handle = Qfalse;
+ state = 0;
+ ruby_errinfo = Qnil;
+ case 0:
result = (*b_proc)(data1);
- }
- else if (state == TAG_RAISE) {
- int handle = Qfalse;
- VALUE eclass;
-
+ break;
+ case TAG_RAISE:
+ if (handle) break;
+ handle = Qfalse;
va_init_list(args, data2);
while (eclass = va_arg(args, VALUE)) {
if (rb_obj_is_kind_of(ruby_errinfo, eclass)) {
@@ -5262,25 +5268,14 @@ rb_rescue2(b_proc, data1, r_proc, data2, va_alist)
va_end(args);
if (handle) {
+ state = 0;
if (r_proc) {
- PUSH_TAG(PROT_NONE);
- if ((state = EXEC_TAG()) == 0) {
- result = (*r_proc)(data2, ruby_errinfo);
- }
- POP_TAG();
- if (state == TAG_RETRY) {
- state = 0;
- ruby_errinfo = Qnil;
- goto retry_entry;
- }
+ result = (*r_proc)(data2, ruby_errinfo);
}
else {
result = Qnil;
- state = 0;
- }
- if (state == 0) {
- ruby_errinfo = e_info;
}
+ ruby_errinfo = e_info;
}
}
POP_TAG();
diff --git a/range.c b/range.c
index a0ae98cba4..3f575de91b 100644
--- a/range.c
+++ b/range.c
@@ -29,11 +29,7 @@ static VALUE
range_check(args)
VALUE *args;
{
- VALUE v;
-
- v = rb_funcall(args[0], id_cmp, 1, args[1]);
- if (NIL_P(v)) range_failed();
- return Qnil;
+ return rb_funcall(args[0], id_cmp, 1, args[1]);
}
static void
@@ -47,7 +43,10 @@ range_init(range, beg, end, exclude_end)
args[1] = end;
if (!FIXNUM_P(beg) || !FIXNUM_P(end)) {
- rb_rescue(range_check, (VALUE)args, range_failed, 0);
+ VALUE v;
+
+ v = rb_rescue(range_check, (VALUE)args, range_failed, 0);
+ if (NIL_P(v)) range_failed();
}
SET_EXCL(range, exclude_end);