ruby-changes:46417
From: nobu <ko1@a...>
Date: Mon, 1 May 2017 09:35:06 +0900 (JST)
Subject: [ruby-changes:46417] nobu:r58525 (trunk): zlib.c: zstream_buffer_ungetbyte
nobu 2017-05-01 09:35:02 +0900 (Mon, 01 May 2017) New Revision: 58525 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=58525 Log: zlib.c: zstream_buffer_ungetbyte * ext/zlib/zlib.c (zstream_buffer_ungetbyte): simplify by using zstream_buffer_ungets(). Modified files: trunk/ext/zlib/zlib.c Index: ext/zlib/zlib.c =================================================================== --- ext/zlib/zlib.c (revision 58524) +++ ext/zlib/zlib.c (revision 58525) @@ -829,17 +829,8 @@ zstream_buffer_ungets(struct zstream *z, https://github.com/ruby/ruby/blob/trunk/ext/zlib/zlib.c#L829 static void zstream_buffer_ungetbyte(struct zstream *z, int c) { - if (NIL_P(z->buf) || RSTRING_LEN(z->buf) - z->buf_filled == 0) { - zstream_expand_buffer(z); - } - - memmove(RSTRING_PTR(z->buf) + 1, RSTRING_PTR(z->buf), z->buf_filled); - RSTRING_PTR(z->buf)[0] = (char)c; - z->buf_filled++; - if (z->stream.avail_out > 0) { - z->stream.next_out++; - z->stream.avail_out--; - } + Bytef cc = (Bytef)c; + zstream_buffer_ungets(z, &cc, 1); } static void -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/