summaryrefslogtreecommitdiff
path: root/test/ruby/test_defined.rb
diff options
context:
space:
mode:
authorYusuke Endoh <mame@ruby-lang.org>2023-12-27 15:45:09 +0900
committergit <svn-admin@ruby-lang.org>2024-10-17 08:54:46 +0000
commit88719fb300e0c6f5d8269224a3322e9871ad29b2 (patch)
treea70caf7dff6b3878586fc442c310ac63e63408bb /test/ruby/test_defined.rb
parentfb84aa550183dd923d287779c242a12f81e17493 (diff)
[ruby/json] Stop prebuilding array_delim
The purpose of this change is to exploit `fbuffer_append_char` that is faster than `fbuffer_append`. `array_delim` was a buffer that concatenated a single comma with `array_nl`. However, in the typical use case (`JSON.generate(data)`), `array_nl` is empty. This means that `array_delim` was a single-character buffer in many cases. `fbuffer_append(buffer, array_delim)` used `memcpy` to copy one byte, which was not so efficient. Rather, this change uses `fbuffer_append_char(buffer, ',')` and then `fbuffer_append(buffer, array_nl)` only when `array_nl` is not NULL. This speeds up `JSON.generate` by about 9% in a benchmark. https://github.com/ruby/json/commit/445de6e459
Diffstat (limited to 'test/ruby/test_defined.rb')
0 files changed, 0 insertions, 0 deletions