summaryrefslogtreecommitdiff
path: root/ext/stringio/stringio.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-06-09 04:44:32 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-06-09 04:44:32 +0000
commita48731e78902abf2469e2cf0486cd17453e6273e (patch)
tree8587803c9b77aff86eeca131d5562652ef0494df /ext/stringio/stringio.c
parent075cf3d2e85729143f7698303e5dc898c516eafa (diff)
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
Diffstat (limited to 'ext/stringio/stringio.c')
-rw-r--r--ext/stringio/stringio.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/ext/stringio/stringio.c b/ext/stringio/stringio.c
index 7dd6d4f..4fdc4df 100644
--- a/ext/stringio/stringio.c
+++ b/ext/stringio/stringio.c
@@ -29,7 +29,7 @@ struct StringIO {
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);
#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();
}
rb_call_super(0, 0);
- strio_init(argc, argv, ptr, self);
- return self;
+ return strio_init(argc, argv, ptr, self);
}
-static void
+static VALUE
strio_init(int argc, VALUE *argv, struct StringIO *ptr, VALUE self)
{
VALUE string, mode;
@@ -223,6 +222,7 @@ strio_init(int argc, VALUE *argv, struct StringIO *ptr, VALUE self)
ptr->pos = 0;
ptr->lineno = 0;
RBASIC(self)->flags |= (ptr->flags & FMODE_READWRITE) * (STRIO_READABLE / FMODE_READABLE);
+ return self;
}
static VALUE
@@ -548,8 +548,7 @@ strio_reopen(int argc, VALUE *argv, VALUE self)
if (argc == 1 && !RB_TYPE_P(*argv, T_STRING)) {
return strio_copy(self, *argv);
}
- strio_init(argc, argv, StringIO(self), self);
- return self;
+ return strio_init(argc, argv, StringIO(self), self);
}
/*