mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
Using UNDEF_P macro
This commit is contained in:
parent
dc1c4e4675
commit
1f4f6c9832
Notes:
git
2022-11-16 09:58:53 +00:00
44 changed files with 290 additions and 290 deletions
60
enum.c
60
enum.c
|
@ -779,7 +779,7 @@ inject_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, p))
|
|||
|
||||
ENUM_WANT_SVALUE();
|
||||
|
||||
if (memo->v1 == Qundef) {
|
||||
if (UNDEF_P(memo->v1)) {
|
||||
MEMO_V1_SET(memo, i);
|
||||
}
|
||||
else {
|
||||
|
@ -796,7 +796,7 @@ inject_op_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, p))
|
|||
|
||||
ENUM_WANT_SVALUE();
|
||||
|
||||
if (memo->v1 == Qundef) {
|
||||
if (UNDEF_P(memo->v1)) {
|
||||
MEMO_V1_SET(memo, i);
|
||||
}
|
||||
else if (SYMBOL_P(name = memo->u3.value)) {
|
||||
|
@ -820,9 +820,9 @@ ary_inject_op(VALUE ary, VALUE init, VALUE op)
|
|||
long i, n;
|
||||
|
||||
if (RARRAY_LEN(ary) == 0)
|
||||
return init == Qundef ? Qnil : init;
|
||||
return UNDEF_P(init) ? Qnil : init;
|
||||
|
||||
if (init == Qundef) {
|
||||
if (UNDEF_P(init)) {
|
||||
v = RARRAY_AREF(ary, 0);
|
||||
i = 1;
|
||||
if (RARRAY_LEN(ary) == 1)
|
||||
|
@ -1051,7 +1051,7 @@ enum_inject(int argc, VALUE *argv, VALUE obj)
|
|||
|
||||
memo = MEMO_NEW(init, Qnil, op);
|
||||
rb_block_call(obj, id_each, 0, 0, iter, (VALUE)memo);
|
||||
if (memo->v1 == Qundef) return Qnil;
|
||||
if (UNDEF_P(memo->v1)) return Qnil;
|
||||
return memo->v1;
|
||||
}
|
||||
|
||||
|
@ -1677,7 +1677,7 @@ enum_any(int argc, VALUE *argv, VALUE obj)
|
|||
DEFINE_ENUMFUNCS(one)
|
||||
{
|
||||
if (RTEST(result)) {
|
||||
if (memo->v1 == Qundef) {
|
||||
if (UNDEF_P(memo->v1)) {
|
||||
MEMO_V1_SET(memo, Qtrue);
|
||||
}
|
||||
else if (memo->v1 == Qtrue) {
|
||||
|
@ -1827,7 +1827,7 @@ nmin_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, _data))
|
|||
else
|
||||
cmpv = i;
|
||||
|
||||
if (data->limit != Qundef) {
|
||||
if (!UNDEF_P(data->limit)) {
|
||||
int c = data->cmpfunc(&cmpv, &data->limit, data);
|
||||
if (data->rev)
|
||||
c = -c;
|
||||
|
@ -1962,7 +1962,7 @@ enum_one(int argc, VALUE *argv, VALUE obj)
|
|||
WARN_UNUSED_BLOCK(argc);
|
||||
rb_block_call(obj, id_each, 0, 0, ENUMFUNC(one), (VALUE)memo);
|
||||
result = memo->v1;
|
||||
if (result == Qundef) return Qfalse;
|
||||
if (UNDEF_P(result)) return Qfalse;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -2037,7 +2037,7 @@ min_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, args))
|
|||
|
||||
ENUM_WANT_SVALUE();
|
||||
|
||||
if (memo->min == Qundef) {
|
||||
if (UNDEF_P(memo->min)) {
|
||||
memo->min = i;
|
||||
}
|
||||
else {
|
||||
|
@ -2056,7 +2056,7 @@ min_ii(RB_BLOCK_CALL_FUNC_ARGLIST(i, args))
|
|||
|
||||
ENUM_WANT_SVALUE();
|
||||
|
||||
if (memo->min == Qundef) {
|
||||
if (UNDEF_P(memo->min)) {
|
||||
memo->min = i;
|
||||
}
|
||||
else {
|
||||
|
@ -2147,7 +2147,7 @@ enum_min(int argc, VALUE *argv, VALUE obj)
|
|||
rb_block_call(obj, id_each, 0, 0, min_i, memo);
|
||||
}
|
||||
result = m->min;
|
||||
if (result == Qundef) return Qnil;
|
||||
if (UNDEF_P(result)) return Qnil;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -2163,7 +2163,7 @@ max_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, args))
|
|||
|
||||
ENUM_WANT_SVALUE();
|
||||
|
||||
if (memo->max == Qundef) {
|
||||
if (UNDEF_P(memo->max)) {
|
||||
memo->max = i;
|
||||
}
|
||||
else {
|
||||
|
@ -2182,7 +2182,7 @@ max_ii(RB_BLOCK_CALL_FUNC_ARGLIST(i, args))
|
|||
|
||||
ENUM_WANT_SVALUE();
|
||||
|
||||
if (memo->max == Qundef) {
|
||||
if (UNDEF_P(memo->max)) {
|
||||
memo->max = i;
|
||||
}
|
||||
else {
|
||||
|
@ -2272,7 +2272,7 @@ enum_max(int argc, VALUE *argv, VALUE obj)
|
|||
rb_block_call(obj, id_each, 0, 0, max_i, (VALUE)memo);
|
||||
}
|
||||
result = m->max;
|
||||
if (result == Qundef) return Qnil;
|
||||
if (UNDEF_P(result)) return Qnil;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -2288,7 +2288,7 @@ minmax_i_update(VALUE i, VALUE j, struct minmax_t *memo)
|
|||
{
|
||||
int n;
|
||||
|
||||
if (memo->min == Qundef) {
|
||||
if (UNDEF_P(memo->min)) {
|
||||
memo->min = i;
|
||||
memo->max = j;
|
||||
}
|
||||
|
@ -2313,7 +2313,7 @@ minmax_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, _memo))
|
|||
|
||||
ENUM_WANT_SVALUE();
|
||||
|
||||
if (memo->last == Qundef) {
|
||||
if (UNDEF_P(memo->last)) {
|
||||
memo->last = i;
|
||||
return Qnil;
|
||||
}
|
||||
|
@ -2340,7 +2340,7 @@ minmax_ii_update(VALUE i, VALUE j, struct minmax_t *memo)
|
|||
{
|
||||
int n;
|
||||
|
||||
if (memo->min == Qundef) {
|
||||
if (UNDEF_P(memo->min)) {
|
||||
memo->min = i;
|
||||
memo->max = j;
|
||||
}
|
||||
|
@ -2365,7 +2365,7 @@ minmax_ii(RB_BLOCK_CALL_FUNC_ARGLIST(i, _memo))
|
|||
|
||||
ENUM_WANT_SVALUE();
|
||||
|
||||
if (memo->last == Qundef) {
|
||||
if (UNDEF_P(memo->last)) {
|
||||
memo->last = i;
|
||||
return Qnil;
|
||||
}
|
||||
|
@ -2430,15 +2430,15 @@ enum_minmax(VALUE obj)
|
|||
m->cmp_opt.opt_inited = 0;
|
||||
if (rb_block_given_p()) {
|
||||
rb_block_call(obj, id_each, 0, 0, minmax_ii, memo);
|
||||
if (m->last != Qundef)
|
||||
if (!UNDEF_P(m->last))
|
||||
minmax_ii_update(m->last, m->last, m);
|
||||
}
|
||||
else {
|
||||
rb_block_call(obj, id_each, 0, 0, minmax_i, memo);
|
||||
if (m->last != Qundef)
|
||||
if (!UNDEF_P(m->last))
|
||||
minmax_i_update(m->last, m->last, m);
|
||||
}
|
||||
if (m->min != Qundef) {
|
||||
if (!UNDEF_P(m->min)) {
|
||||
return rb_assoc_new(m->min, m->max);
|
||||
}
|
||||
return rb_assoc_new(Qnil, Qnil);
|
||||
|
@ -2454,7 +2454,7 @@ min_by_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, args))
|
|||
ENUM_WANT_SVALUE();
|
||||
|
||||
v = enum_yield(argc, i);
|
||||
if (memo->v1 == Qundef) {
|
||||
if (UNDEF_P(memo->v1)) {
|
||||
MEMO_V1_SET(memo, v);
|
||||
MEMO_V2_SET(memo, i);
|
||||
}
|
||||
|
@ -2529,7 +2529,7 @@ max_by_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, args))
|
|||
ENUM_WANT_SVALUE();
|
||||
|
||||
v = enum_yield(argc, i);
|
||||
if (memo->v1 == Qundef) {
|
||||
if (UNDEF_P(memo->v1)) {
|
||||
MEMO_V1_SET(memo, v);
|
||||
MEMO_V2_SET(memo, i);
|
||||
}
|
||||
|
@ -2608,7 +2608,7 @@ minmax_by_i_update(VALUE v1, VALUE v2, VALUE i1, VALUE i2, struct minmax_by_t *m
|
|||
{
|
||||
struct cmp_opt_data cmp_opt = { 0, 0 };
|
||||
|
||||
if (memo->min_bv == Qundef) {
|
||||
if (UNDEF_P(memo->min_bv)) {
|
||||
memo->min_bv = v1;
|
||||
memo->max_bv = v2;
|
||||
memo->min = i1;
|
||||
|
@ -2638,7 +2638,7 @@ minmax_by_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, _memo))
|
|||
|
||||
vi = enum_yield(argc, i);
|
||||
|
||||
if (memo->last_bv == Qundef) {
|
||||
if (UNDEF_P(memo->last_bv)) {
|
||||
memo->last_bv = vi;
|
||||
memo->last = i;
|
||||
return Qnil;
|
||||
|
@ -2705,7 +2705,7 @@ enum_minmax_by(VALUE obj)
|
|||
m->last_bv = Qundef;
|
||||
m->last = Qundef;
|
||||
rb_block_call(obj, id_each, 0, 0, minmax_by_i, memo);
|
||||
if (m->last_bv != Qundef)
|
||||
if (!UNDEF_P(m->last_bv))
|
||||
minmax_by_i_update(m->last_bv, m->last_bv, m->last, m->last, m);
|
||||
m = MEMO_FOR(struct minmax_by_t, memo);
|
||||
return rb_assoc_new(m->min, m->max);
|
||||
|
@ -3185,7 +3185,7 @@ zip_i(RB_BLOCK_CALL_FUNC_ARGLIST(val, memoval))
|
|||
|
||||
v[1] = RARRAY_AREF(args, i);
|
||||
rb_rescue2(call_next, (VALUE)v, call_stop, (VALUE)v, rb_eStopIteration, (VALUE)0);
|
||||
if (v[0] == Qundef) {
|
||||
if (UNDEF_P(v[0])) {
|
||||
RARRAY_ASET(args, i, Qnil);
|
||||
v[0] = Qnil;
|
||||
}
|
||||
|
@ -4155,7 +4155,7 @@ slicewhen_ii(RB_BLOCK_CALL_FUNC_ARGLIST(i, _memo))
|
|||
|
||||
ENUM_WANT_SVALUE();
|
||||
|
||||
if (memo->prev_elt == Qundef) {
|
||||
if (UNDEF_P(memo->prev_elt)) {
|
||||
/* The first element */
|
||||
memo->prev_elt = i;
|
||||
memo->prev_elts = rb_ary_new3(1, i);
|
||||
|
@ -4395,7 +4395,7 @@ sum_iter_bignum(VALUE i, struct enum_sum_memo *memo)
|
|||
static void
|
||||
sum_iter_rational(VALUE i, struct enum_sum_memo *memo)
|
||||
{
|
||||
if (memo->r == Qundef) {
|
||||
if (UNDEF_P(memo->r)) {
|
||||
memo->r = i;
|
||||
}
|
||||
else {
|
||||
|
@ -4616,7 +4616,7 @@ enum_sum(int argc, VALUE* argv, VALUE obj)
|
|||
else {
|
||||
if (memo.n != 0)
|
||||
memo.v = rb_fix_plus(LONG2FIX(memo.n), memo.v);
|
||||
if (memo.r != Qundef) {
|
||||
if (!UNDEF_P(memo.r)) {
|
||||
memo.v = rb_rational_plus(memo.r, memo.v);
|
||||
}
|
||||
return memo.v;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue