in reply to Re^4: XS/Inline::C concat *any* two SVs.
in thread XS/Inline::C concat *any* two SVs.
That's easy, but in this case you must work not with SV but refernce to SV, and dereference it properly.
Let us start with perl stub of what you're trying to achieve
sub test { my $ref = shift; $$ref .= shift; # concatenate, but do efficiently at C level, workin +g with preallocated space }
If this is not what you need, then try expressing in terms of Perl sub your ideas, and we'll translate those to XS... or C.
When you enter a sub, parameters to it are mostly copied (well, sometimes they are aliased but relying on this knowledge will not help you understanding, so let us assume they are copied), so you will not gain speed unless you work with reference.
Regarding your OP code, when you make an illusion of correctly working code, but with mystery "Why do I need to increment the ref count?" this only means you got a SV leak. I can explain it, if needed.
PS sorry my frustrated reply, but once you'll explain your subroutine better I will reply better :)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: XS/Inline::C concat *any* two SVs.
by BrowserUk (Patriarch) on May 29, 2006 at 04:29 UTC | |
by vkon (Curate) on May 29, 2006 at 18:49 UTC | |
by BrowserUk (Patriarch) on May 30, 2006 at 05:59 UTC |