* enumerator.c (get_next_values): extracted from
enumerator_next_values. (enumerator_next_values): use get_next_values. (enumerator_peek_values): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24615 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
a7b920686a
commit
3a855da47b
@ -1,3 +1,10 @@
|
|||||||
|
Fri Aug 21 22:34:58 2009 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
|
* enumerator.c (get_next_values): extracted from
|
||||||
|
enumerator_next_values.
|
||||||
|
(enumerator_next_values): use get_next_values.
|
||||||
|
(enumerator_peek_values): ditto.
|
||||||
|
|
||||||
Fri Aug 21 17:01:04 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Fri Aug 21 17:01:04 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* enc/unicode/name2ctype.h: split from enc/unicode.c and made a
|
* enc/unicode/name2ctype.h: split from enc/unicode.c and made a
|
||||||
|
61
enumerator.c
61
enumerator.c
@ -594,6 +594,31 @@ next_init(VALUE obj, struct enumerator *e)
|
|||||||
e->lookahead = Qundef;
|
e->lookahead = Qundef;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static VALUE
|
||||||
|
get_next_values(VALUE obj, struct enumerator *e)
|
||||||
|
{
|
||||||
|
VALUE curr, vs;
|
||||||
|
|
||||||
|
if (e->stop_exc)
|
||||||
|
rb_exc_raise(e->stop_exc);
|
||||||
|
|
||||||
|
curr = rb_fiber_current();
|
||||||
|
|
||||||
|
if (!e->fib || !rb_fiber_alive_p(e->fib)) {
|
||||||
|
next_init(obj, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
vs = rb_fiber_resume(e->fib, 1, &curr);
|
||||||
|
if (e->stop_exc) {
|
||||||
|
e->fib = 0;
|
||||||
|
e->dst = Qnil;
|
||||||
|
e->lookahead = Qundef;
|
||||||
|
e->feedvalue = Qundef;
|
||||||
|
rb_exc_raise(e->stop_exc);
|
||||||
|
}
|
||||||
|
return vs;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* e.next_values => array
|
* e.next_values => array
|
||||||
@ -642,32 +667,15 @@ static VALUE
|
|||||||
enumerator_next_values(VALUE obj)
|
enumerator_next_values(VALUE obj)
|
||||||
{
|
{
|
||||||
struct enumerator *e = enumerator_ptr(obj);
|
struct enumerator *e = enumerator_ptr(obj);
|
||||||
VALUE curr, v;
|
VALUE vs;
|
||||||
|
|
||||||
if (e->lookahead != Qundef) {
|
if (e->lookahead != Qundef) {
|
||||||
v = e->lookahead;
|
vs = e->lookahead;
|
||||||
e->lookahead = Qundef;
|
e->lookahead = Qundef;
|
||||||
return v;
|
return vs;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (e->stop_exc)
|
return get_next_values(obj, e);
|
||||||
rb_exc_raise(e->stop_exc);
|
|
||||||
|
|
||||||
curr = rb_fiber_current();
|
|
||||||
|
|
||||||
if (!e->fib || !rb_fiber_alive_p(e->fib)) {
|
|
||||||
next_init(obj, e);
|
|
||||||
}
|
|
||||||
|
|
||||||
v = rb_fiber_resume(e->fib, 1, &curr);
|
|
||||||
if (e->stop_exc) {
|
|
||||||
e->fib = 0;
|
|
||||||
e->dst = Qnil;
|
|
||||||
e->lookahead = Qundef;
|
|
||||||
e->feedvalue = Qundef;
|
|
||||||
rb_exc_raise(e->stop_exc);
|
|
||||||
}
|
|
||||||
return v;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
@ -738,16 +746,11 @@ static VALUE
|
|||||||
enumerator_peek_values(VALUE obj)
|
enumerator_peek_values(VALUE obj)
|
||||||
{
|
{
|
||||||
struct enumerator *e = enumerator_ptr(obj);
|
struct enumerator *e = enumerator_ptr(obj);
|
||||||
VALUE v;
|
|
||||||
|
|
||||||
if (e->lookahead != Qundef) {
|
if (e->lookahead == Qundef) {
|
||||||
v = e->lookahead;
|
e->lookahead = get_next_values(obj, e);
|
||||||
return v;
|
|
||||||
}
|
}
|
||||||
|
return e->lookahead;
|
||||||
v = enumerator_next_values(obj);
|
|
||||||
e->lookahead = v;
|
|
||||||
return v;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user