Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
Why does Array#first not use rb_ary_subseq?
Stefan Rusterholz
5/18/2007 12:36:00 PM
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
--
Posted via
http://www.ruby-...
.
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Why does Array#first not use rb_ary_subseq?
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password