in reply to Re^2: XS efficient copy
in thread XS efficient copy

Thanks, your code works, and helped me figure it out.
I had two problems.
SvPOK_on must be called at some point, otherwise, even though it contains data, perl doesn't 'know' that it contains data. Also, I wasn't setting the SvCUR_set, which makes perl think I had an empty string.
I went through several variations on this theme, but all of them were missing that key piece... which makes perfect sense after reading perlguts a bit more carefully.

Replies are listed 'Best First'.
Re^4: XS efficient copy
by creamygoodness (Curate) on Apr 07, 2006 at 18:19 UTC

    perlguts doesn't cover the writing of strings as fully as it does reading. I went through the same confusion -- earlier versions of one of my XS distros, Sort::External, performed unnecessary copy operations before I figured it out.

    Spelunking sv.h and sv.c in the Perl source can be very helpful.

    --
    Marvin Humphrey
    Rectangular Research ― http://www.rectangular.com