S
Stefan Rusterholz
Hi there
When I run a small bench I noticed that Array#first(n) with an argument
is vastly slower than Array#[0,n].
Poking a bit in the source revealed that Array#[] uses rb_ary_subseq,
which seems to create a COW Array while Array#first creates a new Array
on its own and fills it with values. Is there any rationale as to why
Array#first doesn't just use rb_ary_subseq too?
I searched the ML for an answer to this and found none. Forgive me
please if I overlooked the answer.
Regards
Stefan Rusterholz
When I run a small bench I noticed that Array#first(n) with an argument
is vastly slower than Array#[0,n].
Poking a bit in the source revealed that Array#[] uses rb_ary_subseq,
which seems to create a COW Array while Array#first creates a new Array
on its own and fills it with values. Is there any rationale as to why
Array#first doesn't just use rb_ary_subseq too?
I searched the ML for an answer to this and found none. Forgive me
please if I overlooked the answer.
Regards
Stefan Rusterholz