mirror of
https://github.com/ruby/ruby.git
synced 2026-01-26 04:07:58 +00:00
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:
parent
3363861a5a
commit
a071078e90
Notes:
git
2026-01-11 12:43:04 +00:00
2
pack.c
2
pack.c
@ -736,7 +736,7 @@ pack_pack(rb_execution_context_t *ec, VALUE ary, VALUE fmt, VALUE buffer)
|
|||||||
|
|
||||||
case 'w': /* BER compressed integer */
|
case 'w': /* BER compressed integer */
|
||||||
while (len-- > 0) {
|
while (len-- > 0) {
|
||||||
VALUE buf = rb_str_new(0, 0);
|
VALUE buf;
|
||||||
size_t numbytes;
|
size_t numbytes;
|
||||||
int sign;
|
int sign;
|
||||||
char *cp;
|
char *cp;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user