From: Kouhei S. <nu...@co...> - 2017-11-09 14:47:35
|
Kouhei Sutou 2017-11-09 23:46:40 +0900 (Thu, 09 Nov 2017) New Revision: 6b0e74dc6ad90fc0c36868089405508f77b7c69c https://github.com/ruby-gnome2/ruby-gnome2/commit/6b0e74dc6ad90fc0c36868089405508f77b7c69c Message: glib2: GByte#new(frozen_string) doesn't copy string data It'll reduce memory usage. Modified files: glib2/ext/glib2/rbglib-bytes.c Modified: glib2/ext/glib2/rbglib-bytes.c (+5 -1) =================================================================== --- glib2/ext/glib2/rbglib-bytes.c 2017-11-09 23:13:22 +0900 (2c2d00252) +++ glib2/ext/glib2/rbglib-bytes.c 2017-11-09 23:46:40 +0900 (efc44d2b7) @@ -38,7 +38,11 @@ rg_initialize(int argc, VALUE *argv, VALUE self) bytes = g_bytes_new(NULL, 0); } else { const gchar *data = RVAL2CSTR_PTR(rb_data); - bytes = g_bytes_new(data, RSTRING_LEN(rb_data)); + if (RB_OBJ_FROZEN(rb_data)) { + bytes = g_bytes_new_static(data, RSTRING_LEN(rb_data)); + } else { + bytes = g_bytes_new(data, RSTRING_LEN(rb_data)); + } } G_INITIALIZE(self, bytes); |