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

ruby-changes:46424

From: nobu <ko1@a...>
Date: Mon, 1 May 2017 09:35:05 +0900 (JST)
Subject: [ruby-changes:46424] nobu:r58524 (trunk): zlib.c: zstream_expand_buffer_non_stream

nobu	2017-05-01 09:35:00 +0900 (Mon, 01 May 2017)

  New Revision: 58524

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

  Log:
    zlib.c: zstream_expand_buffer_non_stream
    
    * ext/zlib/zlib.c (zstream_expand_buffer_non_stream): rename from
      zstream_expand_buffer_without_gvl() and replace duplicate code
      in zstream_expand_buffer().

  Modified files:
    trunk/ext/zlib/zlib.c
Index: ext/zlib/zlib.c
===================================================================
--- ext/zlib/zlib.c	(revision 58523)
+++ ext/zlib/zlib.c	(revision 58524)
@@ -72,6 +72,7 @@ struct zstream_run_args; https://github.com/ruby/ruby/blob/trunk/ext/zlib/zlib.c#L72
 static void zstream_init(struct zstream*, const struct zstream_funcs*);
 static void zstream_expand_buffer(struct zstream*);
 static void zstream_expand_buffer_into(struct zstream*, unsigned long);
+static int zstream_expand_buffer_non_stream(struct zstream *z);
 static void zstream_append_buffer(struct zstream*, const Bytef*, long);
 static VALUE zstream_detach_buffer(struct zstream*);
 static VALUE zstream_shift_buffer(struct zstream*, long);
@@ -648,19 +649,7 @@ zstream_expand_buffer(struct zstream *z) https://github.com/ruby/ruby/blob/trunk/ext/zlib/zlib.c#L649
 	}
     }
     else {
-	if (RSTRING_LEN(z->buf) - z->buf_filled >= ZSTREAM_AVAIL_OUT_STEP_MAX) {
-	    z->stream.avail_out = ZSTREAM_AVAIL_OUT_STEP_MAX;
-	}
-	else {
-	    long inc = z->buf_filled / 2;
-	    if (inc < ZSTREAM_AVAIL_OUT_STEP_MIN) {
-		inc = ZSTREAM_AVAIL_OUT_STEP_MIN;
-	    }
-	    rb_str_resize(z->buf, z->buf_filled + inc);
-	    z->stream.avail_out = (inc < ZSTREAM_AVAIL_OUT_STEP_MAX) ?
-		(int)inc : ZSTREAM_AVAIL_OUT_STEP_MAX;
-	}
-	z->stream.next_out = (Bytef*)RSTRING_PTR(z->buf) + z->buf_filled;
+	zstream_expand_buffer_non_stream(z);
     }
 }
 
@@ -695,7 +684,7 @@ zstream_expand_buffer_protect(void *ptr) https://github.com/ruby/ruby/blob/trunk/ext/zlib/zlib.c#L684
 }
 
 static int
-zstream_expand_buffer_without_gvl(struct zstream *z)
+zstream_expand_buffer_non_stream(struct zstream *z)
 {
     char * new_str;
     long inc, len;
@@ -997,7 +986,7 @@ zstream_run_func(void *ptr) https://github.com/ruby/ruby/blob/trunk/ext/zlib/zlib.c#L986
 							(void *)z);
 	}
 	else {
-	    state = zstream_expand_buffer_without_gvl(z);
+	    state = zstream_expand_buffer_non_stream(z);
 	}
 
 	if (state) {

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

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