summaryrefslogtreecommitdiff
path: root/file.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 /file.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 'file.c')
-rw-r--r--file.c29
1 files changed, 14 insertions, 15 deletions
diff --git a/file.c b/file.c
index e49005be97..712772ebf8 100644
--- a/file.c
+++ b/file.c
@@ -125,15 +125,14 @@ apply2files(void (*func)(const char *, void *), VALUE vargs, void *arg)
{
long i;
VALUE path;
- struct RArray *args = RARRAY(vargs);
rb_secure(4);
- for (i=0; i<args->len; i++) {
- path = rb_get_path(args->ptr[i]);
+ for (i=0; i<RARRAY_LEN(vargs); i++) {
+ path = rb_get_path(RARRAY_PTR(vargs)[i]);
(*func)(StringValueCStr(path), arg);
}
- return args->len;
+ return RARRAY_LEN(vargs);
}
/*
@@ -2875,12 +2874,12 @@ rb_file_join(VALUE ary, VALUE sep)
VALUE result, tmp;
char *name, *tail;
- if (RARRAY(ary)->len == 0) return rb_str_new(0, 0);
+ if (RARRAY_LEN(ary) == 0) return rb_str_new(0, 0);
len = 1;
- for (i=0; i<RARRAY(ary)->len; i++) {
- if (TYPE(RARRAY(ary)->ptr[i]) == T_STRING) {
- len += RSTRING_LEN(RARRAY(ary)->ptr[i]);
+ for (i=0; i<RARRAY_LEN(ary); i++) {
+ if (TYPE(RARRAY_PTR(ary)[i]) == T_STRING) {
+ len += RSTRING_LEN(RARRAY_PTR(ary)[i]);
}
else {
len += 10;
@@ -2888,12 +2887,12 @@ rb_file_join(VALUE ary, VALUE sep)
}
if (!NIL_P(sep)) {
StringValue(sep);
- len += RSTRING_LEN(sep) * RARRAY(ary)->len - 1;
+ len += RSTRING_LEN(sep) * RARRAY_LEN(ary) - 1;
}
result = rb_str_buf_new(len);
OBJ_INFECT(result, ary);
- for (i=0; i<RARRAY(ary)->len; i++) {
- tmp = RARRAY(ary)->ptr[i];
+ for (i=0; i<RARRAY_LEN(ary); i++) {
+ tmp = RARRAY_PTR(ary)[i];
switch (TYPE(tmp)) {
case T_STRING:
break;
@@ -4174,8 +4173,8 @@ rb_find_file_ext(VALUE *filep, const char *const *ext)
if (!rb_load_path) return 0;
Check_Type(rb_load_path, T_ARRAY);
- for (i=0;i<RARRAY(rb_load_path)->len;i++) {
- VALUE str = RARRAY(rb_load_path)->ptr[i];
+ for (i=0;i<RARRAY_LEN(rb_load_path);i++) {
+ VALUE str = RARRAY_PTR(rb_load_path)[i];
FilePathValue(str);
if (RSTRING_LEN(str) == 0) continue;
@@ -4235,8 +4234,8 @@ rb_find_file(VALUE path)
Check_Type(rb_load_path, T_ARRAY);
tmp = rb_ary_new();
- for (i=0;i<RARRAY(rb_load_path)->len;i++) {
- VALUE str = RARRAY(rb_load_path)->ptr[i];
+ for (i=0;i<RARRAY_LEN(rb_load_path);i++) {
+ VALUE str = RARRAY_PTR(rb_load_path)[i];
FilePathValue(str);
if (RSTRING_LEN(str) > 0) {
rb_ary_push(tmp, str);