strio_init: return self for tail call optimization
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55333 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
075cf3d2e8
commit
a48731e789
@ -29,7 +29,7 @@ struct StringIO {
|
|||||||
int count;
|
int count;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void strio_init(int, VALUE *, struct StringIO *, VALUE);
|
static VALUE strio_init(int, VALUE *, struct StringIO *, VALUE);
|
||||||
static VALUE strio_unget_bytes(struct StringIO *, const char *, long);
|
static VALUE strio_unget_bytes(struct StringIO *, const char *, long);
|
||||||
|
|
||||||
#define IS_STRIO(obj) (rb_typeddata_is_kind_of((obj), &strio_data_type))
|
#define IS_STRIO(obj) (rb_typeddata_is_kind_of((obj), &strio_data_type))
|
||||||
@ -179,11 +179,10 @@ strio_initialize(int argc, VALUE *argv, VALUE self)
|
|||||||
DATA_PTR(self) = ptr = strio_alloc();
|
DATA_PTR(self) = ptr = strio_alloc();
|
||||||
}
|
}
|
||||||
rb_call_super(0, 0);
|
rb_call_super(0, 0);
|
||||||
strio_init(argc, argv, ptr, self);
|
return strio_init(argc, argv, ptr, self);
|
||||||
return self;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static VALUE
|
||||||
strio_init(int argc, VALUE *argv, struct StringIO *ptr, VALUE self)
|
strio_init(int argc, VALUE *argv, struct StringIO *ptr, VALUE self)
|
||||||
{
|
{
|
||||||
VALUE string, mode;
|
VALUE string, mode;
|
||||||
@ -223,6 +222,7 @@ strio_init(int argc, VALUE *argv, struct StringIO *ptr, VALUE self)
|
|||||||
ptr->pos = 0;
|
ptr->pos = 0;
|
||||||
ptr->lineno = 0;
|
ptr->lineno = 0;
|
||||||
RBASIC(self)->flags |= (ptr->flags & FMODE_READWRITE) * (STRIO_READABLE / FMODE_READABLE);
|
RBASIC(self)->flags |= (ptr->flags & FMODE_READWRITE) * (STRIO_READABLE / FMODE_READABLE);
|
||||||
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
@ -548,8 +548,7 @@ strio_reopen(int argc, VALUE *argv, VALUE self)
|
|||||||
if (argc == 1 && !RB_TYPE_P(*argv, T_STRING)) {
|
if (argc == 1 && !RB_TYPE_P(*argv, T_STRING)) {
|
||||||
return strio_copy(self, *argv);
|
return strio_copy(self, *argv);
|
||||||
}
|
}
|
||||||
strio_init(argc, argv, StringIO(self), self);
|
return strio_init(argc, argv, StringIO(self), self);
|
||||||
return self;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user