in reply to Re: Re: adding null values to the start of an array
in thread adding null values to the start of an array

Yeah!   ;-)   But in the spirit of TMTOWTDI-simply,
splice(@array1,0,0, (undef) x @array2 );
I have no idea which would be faster.

Replies are listed 'Best First'.
Re: Re: Re: Re: adding null values to the start of an array
by etcshadow (Priest) on Oct 09, 2003 at 02:59 UTC
    I'm not positive, but it's my impression that push, pop, shift, and unshift are all implemented as either thin wrappers around splice or thin wrappers around whatever underlies splice. So I think that the most possible difference is a single stack-frame (call unshift, and then unshift calls splice, as opposed to calling splice directly)... but I'm not even sure that that isn't optimized away (as, like, a macro or some such in the underlying C code). To know for sure, I'd have to dig through the C source for the perl core, which I don't really feel like doing right now. ;-)

    ------------
    :Wq
    Not an editor command: Wq