From b6463d59e7c52dd4493796ff1cbd10b5e25caaca Mon Sep 17 00:00:00 2001 From: Scott Myron Date: Fri, 2 Jan 2026 20:47:59 -0600 Subject: [PATCH 1/2] [ruby/json] Directly write to the output buffer when converting UTF32 to UTF8. https://github.com/ruby/json/commit/a51317c949 --- ext/json/parser/parser.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/ext/json/parser/parser.c b/ext/json/parser/parser.c index 0ac16918f876b9..f1ea1b6abbfdc3 100644 --- a/ext/json/parser/parser.c +++ b/ext/json/parser/parser.c @@ -739,9 +739,7 @@ NOINLINE(static) VALUE json_string_unescape(JSON_ParserState *state, JSON_Parser } } - char buf[4]; - int unescape_len = convert_UTF32_to_UTF8(buf, ch); - MEMCPY(buffer, buf, char, unescape_len); + int unescape_len = convert_UTF32_to_UTF8(buffer, ch); buffer += unescape_len; p = ++pe; break; From 65f9c4a06a17368c452bcda7f0e6325ea1d51eba Mon Sep 17 00:00:00 2001 From: Shannon Skipper Date: Thu, 1 Jan 2026 18:15:11 -0800 Subject: [PATCH 2/2] Drop memberless Data/Struct#inspect trailing space Anonymous memberless Structs and Data were returning `#` and `#` with a trailing space. Now they return `#` and `#` to match attrless class behavior and look a bit more compact. --- struct.c | 7 ++++--- test/ruby/test_data.rb | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/struct.c b/struct.c index 31df3798cbcb4b..a438ddd6136092 100644 --- a/struct.c +++ b/struct.c @@ -981,6 +981,7 @@ inspect_struct(VALUE s, VALUE prefix, int recur) char first = RSTRING_PTR(cname)[0]; if (recur || first != '#') { + rb_str_cat2(str, " "); rb_str_append(str, cname); } if (recur) { @@ -997,7 +998,7 @@ inspect_struct(VALUE s, VALUE prefix, int recur) if (i > 0) { rb_str_cat2(str, ", "); } - else if (first != '#') { + else { rb_str_cat2(str, " "); } slot = RARRAY_AREF(members, i); @@ -1031,7 +1032,7 @@ inspect_struct(VALUE s, VALUE prefix, int recur) static VALUE rb_struct_inspect(VALUE s) { - return rb_exec_recursive(inspect_struct, s, rb_str_new2("#', test.inspect) + assert_equal('#', test.inspect) assert_equal([], test.members) assert_equal({}, test.to_h) assert_predicate(test, :frozen?)