develooper Front page | perl.perl5.porters | Postings from April 2010

magic method wrapper

Thread Next
From:
Dave Mitchell
Date:
April 24, 2010 17:14
Subject:
magic method wrapper
Message ID:
20100425001359.GH9972@iabyn.com
Something that's irritated me for years is the fact that code similar to
the following is repeated many times in core:

    dSP;
    PUSHSTACKi(PERLSI_MAGIC);
    PUSHMARK(SP);
    EXTEND(SP,2);
    PUSHs(SvTIED_obj(MUTABLE_SV(av), mg));
    PUSHs(val);
    PUTBACK;
    ENTER;
    call_method("PUSH", G_SCALAR|G_DISCARD);
    LEAVE;
    POPSTACK;

So with commit efaf36747029c85b4d8825318cb4d485a0bb350e I've added a
wrapper function that replaces the above with:

    magic_methcall(MUTABLE_SV(av), mg, "PUSH", G_DISCARD, 1, val, NULL);

and used it in 12 places in the core.

The size of the perl binary under 32-bit -O2 decreased by 4987 bytes, or
0.4%.


-- 
All wight. I will give you one more chance. This time, I want to hear
no Wubens. No Weginalds. No Wudolf the wed-nosed weindeers.
    -- Life of Brian

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About