pack.c: remove wasted allocation in BER integer packing

The 'w' format (BER compressed integer) was allocating an empty
string with rb_str_new(0, 0) then immediately overwriting it with
the correctly-sized allocation. Remove the wasted first allocation.

~50% improvement on BER pack benchmarks.
This commit is contained in:
Chris Hasiński 2026-01-11 03:45:44 +01:00 committed by Nobuyoshi Nakada
parent 3363861a5a
commit a071078e90
Notes: git 2026-01-11 12:43:04 +00:00

2
pack.c
View File

@ -736,7 +736,7 @@ pack_pack(rb_execution_context_t *ec, VALUE ary, VALUE fmt, VALUE buffer)
case 'w': /* BER compressed integer */
while (len-- > 0) {
VALUE buf = rb_str_new(0, 0);
VALUE buf;
size_t numbytes;
int sign;
char *cp;