summaryrefslogtreecommitdiff
path: root/pack.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-09-02 14:42:08 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-09-02 14:42:08 +0000
commit2156870525be05f0bd769af141c3f6cff9fff8c4 (patch)
tree3e6db7f9ecee480edff058e18bc7211a53296f64 /pack.c
parent8581164ea67a13fad5e7d56aa4aa75a87f9eafb3 (diff)
downloadruby-2156870525be05f0bd769af141c3f6cff9fff8c4.tar.gz
* 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
Diffstat (limited to 'pack.c')
-rw-r--r--pack.c18
1 files changed, 9 insertions, 9 deletions
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;