summaryrefslogtreecommitdiff
path: root/enumerator.c
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-12-03 03:51:55 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-12-03 03:51:55 +0000
commit1e9896ae314d23ce813d86796ed3f29669c9db9b (patch)
treecda84e5eecda665caf914bc5c54de6431ea30faa /enumerator.c
parentb65a43ca2f173466e216d6ce268e68ebaff174b0 (diff)
use RARRAY_AREF instead of RARRAY_PTR_USE.
* enumerator.c (enum_chain_total_size): use RARRAY_AREF instead of RARRAY_PTR_USE because we don't need non-const ptr. * enumerator.c (enum_chain_each): ditto. * enumerator.c (enum_chain_rewind): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66148 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'enumerator.c')
-rw-r--r--enumerator.c48
1 files changed, 20 insertions, 28 deletions
diff --git a/enumerator.c b/enumerator.c
index 2eb0c24..e84785a 100644
--- a/enumerator.c
+++ b/enumerator.c
@@ -2530,23 +2530,20 @@ static VALUE
enum_chain_total_size(VALUE enums)
{
VALUE total = INT2FIX(0);
+ long i;
- RARRAY_PTR_USE(enums, ptr, {
- long i;
-
- for (i = 0; i < RARRAY_LEN(enums); i++) {
- VALUE size = enum_size(ptr[i]);
+ for (i = 0; i < RARRAY_LEN(enums); i++) {
+ VALUE size = enum_size(RARRAY_AREF(enums, i));
- if (NIL_P(size) || (RB_TYPE_P(size, T_FLOAT) && isinf(NUM2DBL(size)))) {
- return size;
- }
- if (!RB_INTEGER_TYPE_P(size)) {
- return Qnil;
- }
-
- total = rb_funcall(total, '+', 1, size);
+ if (NIL_P(size) || (RB_TYPE_P(size, T_FLOAT) && isinf(NUM2DBL(size)))) {
+ return size;
+ }
+ if (!RB_INTEGER_TYPE_P(size)) {
+ return Qnil;
}
- });
+
+ total = rb_funcall(total, '+', 1, size);
+ }
return total;
}
@@ -2601,6 +2598,7 @@ enum_chain_each(int argc, VALUE *argv, VALUE obj)
{
VALUE enums, block;
struct enum_chain *objptr;
+ long i;
RETURN_SIZED_ENUMERATOR(obj, argc, argv, argc > 0 ? enum_chain_enum_no_size : enum_chain_enum_size);
@@ -2608,14 +2606,11 @@ enum_chain_each(int argc, VALUE *argv, VALUE obj)
enums = objptr->enums;
block = rb_block_proc();
- RARRAY_PTR_USE(enums, ptr, {
- long i;
- for (i = 0; i < RARRAY_LEN(enums); i++) {
- objptr->pos = i;
- rb_block_call(ptr[i], id_each, argc, argv, enum_chain_yield_block, block);
- }
- });
+ for (i = 0; i < RARRAY_LEN(enums); i++) {
+ objptr->pos = i;
+ rb_block_call(RARRAY_AREF(enums, i), id_each, argc, argv, enum_chain_yield_block, block);
+ }
return obj;
}
@@ -2633,14 +2628,11 @@ enum_chain_rewind(VALUE obj)
{
struct enum_chain *objptr = enum_chain_ptr(obj);
VALUE enums = objptr->enums;
+ long i;
- RARRAY_PTR_USE(enums, ptr, {
- long i;
-
- for (i = objptr->pos; 0 <= i && i < RARRAY_LEN(enums); objptr->pos = --i) {
- rb_check_funcall(ptr[i], id_rewind, 0, 0);
- }
- });
+ for (i = objptr->pos; 0 <= i && i < RARRAY_LEN(enums); objptr->pos = --i) {
+ rb_check_funcall(RARRAY_AREF(enums, i), id_rewind, 0, 0);
+ }
return obj;
}