(Though, I half expect Perl to do @in= @in[@idx]; in-place.)

Seems to me from a quick look at pp_hot.c in perl.git that aassign ops where the LHS and RHS contain common members is actually slower, not faster.

>perl -MO=Concise -e"@in=@in[@idx] e <@> leave[1 ref] vKP/REFC ->(end) 1 <0> enter ->2 2 <;> nextstate(main 1 -e:1) v ->3 d <2> aassign[t7] vKS/COMMON ->e <-- Note "COMMON" - <1> ex-list lK ->a 3 <0> pushmark s ->4 9 <@> aslice lK ->a 4 <0> pushmark s ->5 6 <1> rv2av[t6] lK/1 ->7 5 <#> gv[*idx] s ->6 8 <1> rv2av[t4] sKR/1 ->9 7 <#> gv[*in] s ->8 - <1> ex-list lK ->d a <0> pushmark s ->b c <1> rv2av[t2] lKRM*/1 ->d b <#> gv[*in] s ->c
1 995: /* If there's a common identifier on both +sides we have to take 1 996: * special care that assigning the identif +ier on the left doesn't 1 997: * clobber a value on the right that's use +d later in the list. 1 998: */ 5492 << 999: if (PL_op->op_private & (OPpASSIGN_COMMON) +) { 2062 << 1000: EXTEND_MORTAL(lastrelem - firstrelem + 1); 5492 << 1001: for (relem = firstrelem; relem <= lastrele +m; relem++) { 5540 << 1002: if ((sv = *relem)) { 18 << br 1003: TAINT_NOT; /* Each item is independ +ent */ 5492 << 1004: *relem = sv_mortalcopy(sv); 18 << br 1005: } 5492 << 1006: } 1 1007: } 1 1008:

In reply to Re^9: Sorting a (very) large file (memory) by ikegami
in thread Sorting a (very) large file by condar

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.