From 2156870525be05f0bd769af141c3f6cff9fff8c4 Mon Sep 17 00:00:00 2001 From: matz Date: Sat, 2 Sep 2006 14:42:08 +0000 Subject: * ruby.h (struct RArray): embed small arrays. (RARRAY_LEN): defined for accessing array members. (RARRAY_PTR): ditto. * array.c: use RARRAY_LEN and RARRAY_PTR. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10833 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- pack.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'pack.c') diff --git a/pack.c b/pack.c index 4a567ddce8..7cb6848143 100644 --- a/pack.c +++ b/pack.c @@ -452,12 +452,12 @@ pack_pack(VALUE ary, VALUE fmt) pend = p + RSTRING_LEN(fmt); res = rb_str_buf_new(0); - items = RARRAY(ary)->len; + items = RARRAY_LEN(ary); idx = 0; #define TOO_FEW (rb_raise(rb_eArgError, toofew), 0) -#define THISFROM (items > 0 ? RARRAY(ary)->ptr[idx] : TOO_FEW) -#define NEXTFROM (items-- > 0 ? RARRAY(ary)->ptr[idx++] : TOO_FEW) +#define THISFROM (items > 0 ? RARRAY_PTR(ary)[idx] : TOO_FEW) +#define NEXTFROM (items-- > 0 ? RARRAY_PTR(ary)[idx++] : TOO_FEW) while (p < pend) { if (RSTRING_PTR(fmt) + RSTRING_LEN(fmt) != pend) { @@ -949,9 +949,9 @@ pack_pack(VALUE ary, VALUE fmt) VALUE big128 = rb_uint2big(128); while (TYPE(from) == T_BIGNUM) { from = rb_big_divmod(from, big128); - c = NUM2INT(RARRAY(from)->ptr[1]) | 0x80; /* mod */ + c = NUM2INT(RARRAY_PTR(from)[1]) | 0x80; /* mod */ rb_str_buf_cat(buf, &c, sizeof(char)); - from = RARRAY(from)->ptr[0]; /* div */ + from = RARRAY_PTR(from)[0]; /* div */ } } @@ -1868,8 +1868,8 @@ pack_unpack(VALUE str, VALUE fmt) if (!(a = rb_str_associated(str))) { rb_raise(rb_eArgError, "no associated pointer"); } - p = RARRAY(a)->ptr; - pend = p + RARRAY(a)->len; + p = RARRAY_PTR(a); + pend = p + RARRAY_LEN(a); while (p < pend) { if (TYPE(*p) == T_STRING && RSTRING_PTR(*p) == t) { if (len < RSTRING_LEN(*p)) { @@ -1913,8 +1913,8 @@ pack_unpack(VALUE str, VALUE fmt) if (!(a = rb_str_associated(str))) { rb_raise(rb_eArgError, "no associated pointer"); } - p = RARRAY(a)->ptr; - pend = p + RARRAY(a)->len; + p = RARRAY_PTR(a); + pend = p + RARRAY_LEN(a); while (p < pend) { if (TYPE(*p) == T_STRING && RSTRING_PTR(*p) == t) { tmp = *p; -- cgit v1.2.3