Skip to content

Commit a071078

Browse files
khasinskinobu
authored andcommitted
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.
1 parent 3363861 commit a071078

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

pack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,7 @@ pack_pack(rb_execution_context_t *ec, VALUE ary, VALUE fmt, VALUE buffer)
736736

737737
case 'w': /* BER compressed integer */
738738
while (len-- > 0) {
739-
VALUE buf = rb_str_new(0, 0);
739+
VALUE buf;
740740
size_t numbytes;
741741
int sign;
742742
char *cp;

0 commit comments

Comments
 (0)