but that still leaves me with the question of whether I should be resetting the stack to account for the single input parameter, or whether the EXTEND() takes care for that for me

No - as it stands, the first value that gets returned should be the supplied argument - at least that's what I'm finding. If you want to avoid that, then you need to reset the stack pointer or take some alternative measure.
Ike questions the validity of doing sp = mark though it's something that has been in the Inline test suite for the last few years, and has not produced any problems with the cpan-testers. Is there a better way of resetting the stack pointer ?
I think that, in this instance you could also just sp--; (update: or, more generally, sp -= items) before you EXTEND.

I can't actually find any code of mine that resets the stack pointer - I usually take a different approach such as just assigning to ST(0), ST(1), etc.

I also wonder if I shouldn't be passing in a reference to the an array and populating it directly, rather than assigning the returned stack to it?

I've benchmarked that for some huge arrays in the past ... and not detected any advantage in passing by reference (with Inline::C).

Cheers,
Rob

In reply to Re^5: XS: EXTEND/mPUSHi by syphilis
in thread XS: EXTEND/mPUSHi by BrowserUk

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.