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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |