in reply to Using vec() from XS

Just use sv_insert instead?

Replies are listed 'Best First'.
Re^2: Using vec() from XS
by BrowserUk (Patriarch) on Sep 23, 2008 at 15:56 UTC

    I'm not sure how that helps? vec doesn't do any inserts, just update in-place or grow if the offest calculates beyond the current end of string.

    It isn't too hard to re-code the math and bit-twiddling, the main problem is getting the memory management right. As vec does everything I need (and more), it would have been nice to find a way to re-use that code without having to either c&p or callback to perl in order to do it.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
        ...and the lvalue part just builds an SV with some magic attached and returns it.

        When a set operation is performed on the returned SV, the "set" operation from the magic vtable performs the real set on the original SV (the vector) indirectly

        That can also be easily replicated in XS code.