From 1904581b325c485e96a25b43ca7bfbabe48b4c03 Mon Sep 17 00:00:00 2001 From: Tilman Sauerbeck Date: Mon, 27 Jun 2005 19:22:58 +0000 Subject: [PATCH] Tweaked Stream#serialize to be more GC-friendly. --- ChangeLog | 5 ++++- ext/ext.c | 12 ++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 70f076f..153a5ec 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,10 @@ -- -$Id: ChangeLog 63 2005-06-09 17:47:46Z tilman $ +$Id: ChangeLog 64 2005-06-27 19:22:58Z tilman $ ++ +2005-06-27 Tilman Sauerbeck (tilman at code-monkey de) + * ext/ext.c: Tweaked Stream#serialize to be more GC-friendly + 2005-06-09 Tilman Sauerbeck (tilman at code-monkey de) * ext/ext.c: Object#to_eet: Don't put the final chunk in a stream again, it's not needed diff --git a/ext/ext.c b/ext/ext.c index e36442f..a9f14db 100644 --- a/ext/ext.c +++ b/ext/ext.c @@ -1,5 +1,5 @@ /* - * $Id: ext.c 63 2005-06-09 17:47:46Z tilman $ + * $Id: ext.c 64 2005-06-27 19:22:58Z tilman $ * * Copyright (c) 2005 Tilman Sauerbeck (tilman at code-monkey de) * @@ -444,11 +444,11 @@ stream_serialize (VALUE self) struct RArray *stream; long i; - ret = rb_str_new2 (""); - stream = RARRAY (self); if (!stream->len) - return ret; + return rb_str_new2 (""); + + ret = rb_ary_new (); for (i = 0; i < stream->len; i++) { VALUE str; @@ -458,10 +458,10 @@ stream_serialize (VALUE self) str = rb_funcall (stream->ptr[i], id_serialize, 0, NULL); - rb_str_append (ret, str); + rb_ary_push (ret, str); } - return ret; + return rb_ary_join (ret, Qnil); } static VALUE -- 2.30.2