Hi.

Situation: There is a class with no childs (class can't be inherited by design).

Question: Is it safe to cache stash address in the static var? And using this var in consequent blesses?

(Motivation: performance tuning.)

Example:
<CODE>

static HV* this_stash;

MODULE = StashTest PACKAGE = StashTest

PROTOTYPES: DISABLE

void
new(xclass, sv)
        SV* xclass;
        SV* sv;
    PPCODE:
        ST(0)=sv_2mortal(sv_bless(newRV_inc(newSVsv(sv)), this_stash));
        XSRETURN(1);

BOOT:
{
        this_stash=gv_stashpvn("StashTest", 9, TRUE);
}

</CODE>

Full example:
http://freebsd.org/~skv/perl/StashTest.tgz

--
Sergey Skvortsov
mailto: [EMAIL PROTECTED]

Reply via email to