If it's known that inside an AV* array all the elements are IVs

The elements are never IVs (an integral type big enough to hold an int and big enough to hold a pointer). They are always scalars (SVs).

And no, it's takes too little to convert the type of the SV body to make your plan workable. For example, just by printing the element, you can drastically change it's structure:

use Devel::Peek; $a[0] = 123; Dump $a[0]; print "$a[0]\n"; Dump $a[0];
SV = IV(0x238b30) at 0x238b34 REFCNT = 1 FLAGS = (IOK,pIOK) IV = 123 123 SV = PVIV(0x182005c) at 0x238b34 REFCNT = 1 FLAGS = (IOK,POK,pIOK,pPOK) IV = 123 PV = 0x23f23c "123"\0 CUR = 3 LEN = 4

(Technically, it's the stringification for the concatenation that caused the conversion.)

You could access the SVs in the array via some pointer then use the normal SV macros to get the IV from them. But at this point, you gotta wonder what you are doing using a Perl array. Or Perl. One subroutine call would annihilate any savings.


In reply to Re: Need for (XS) speed by ikegami
in thread Need for (XS) speed by spx2

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.