[前][次][番号順一覧][スレッド一覧]

ruby-changes:43260

From: nobu <ko1@a...>
Date: Thu, 9 Jun 2016 13:44:40 +0900 (JST)
Subject: [ruby-changes:43260] nobu:r55333 (trunk): strio_init: return self for tail call optimization

nobu	2016-06-09 13:44:32 +0900 (Thu, 09 Jun 2016)

  New Revision: 55333

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=55333

  Log:
    strio_init: return self for tail call optimization

  Modified files:
    trunk/ext/stringio/stringio.c
Index: ext/stringio/stringio.c
===================================================================
--- ext/stringio/stringio.c	(revision 55332)
+++ ext/stringio/stringio.c	(revision 55333)
@@ -29,7 +29,7 @@ struct StringIO { https://github.com/ruby/ruby/blob/trunk/ext/stringio/stringio.c#L29
     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, https://github.com/ruby/ruby/blob/trunk/ext/stringio/stringio.c#L179
 	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 https://github.com/ruby/ruby/blob/trunk/ext/stringio/stringio.c#L222
     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, VALU https://github.com/ruby/ruby/blob/trunk/ext/stringio/stringio.c#L548
     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);
 }
 
 /*

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]