On Thu, Sep 20, 2001 at 03:23:19PM +0100, Simon Cozens wrote:
> How about this for an initial suggestion: you (I would do it, but I *really*
> have no time. :( ) grab a copy of Parrot, change one or two of the files to
> look like what they ought to look like.

OK; I've done this. It's a quick sed job after all. :)

Here's one function before:
    /*=for api string_native string_native_substr
       substring out length characters from src starting from offset
       and store in dest.  Grow dest if needed.  Return dest
    */
    static STRING*
    string_native_substr(STRING* src, IV offset, IV length, STRING* dest)
    {
        if (dest->encoding->which != enc_native) {
            /* It is now, matey. */
            dest->encoding = &(Parrot_string_vtable[enc_native]);
        }

        /* Offset and length have already been "normalized" */
        string_grow(dest, length);
        mem_sys_memcopy(dest->bufstart, (void*)((IV)src->bufstart + offset), length);
        dest->strlen = dest->bufused = length;

        return dest;
    }

Here's the same function after:
    /*=for api string_native string_native_substr
       substring out length characters from src starting from offset
       and store in dest.  Grow dest if needed.  Return dest
    */
    static STRING*
    string_native_substr(STRING* src, intval offset, intval length, STRING* dest)
    {
        if (dest->encoding->which != enc_native) {
            /* It is now, matey. */
            dest->encoding = &(Parrot_string_vtable[enc_native]);
        }

        /* Offset and length have already been "normalized" */
        string_grow(dest, length);
        mem_sys_memcopy(dest->bufstart, (void*)((intval)src->bufstart + offset), 
length);
        dest->strlen = dest->bufused = length;

        return dest;
    }

Now, I'm obviously the wrong person to judge this, since I'm pretty entrenched. So,
judges - which is easier to understand? Which would you prefer to deal with? Does it
actually make that much difference?

-- 
I am familiar with this particular stupid user; it lives inside one's head 
and takes control at unexpected moments.
    - Roger Burton West

Reply via email to