From: Florian Ragwitz Date: Wed, 11 Mar 2009 04:57:37 +0000 (+0100) Subject: Inline mop_simple_reader. X-Git-Tag: 0.78_01~64 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=384bb6c99e7c8e724e67a7c8073efeed3b682973;p=gitmo%2FClass-MOP.git Inline mop_simple_reader. --- diff --git a/mop.c b/mop.c index 25358f8..ada6c0e 100644 --- a/mop.c +++ b/mop.c @@ -243,10 +243,22 @@ mop_prehash_keys () } } -SV * -mop_simple_reader (SV *self, mop_prehashed_key_t key) +XS(mop_xs_simple_reader) { +#ifdef dVAR + dVAR; dXSARGS; +#else + dXSARGS; +#endif register HE *he; + mop_prehashed_key_t key = CvXSUBANY(cv).any_i32; + SV *self; + + if (items != 1) { + croak("expected exactly one argument"); + } + + self = ST(0); if (!SvROK(self)) { croak("can't call %s as a class method", prehashed_keys[key].name); @@ -257,26 +269,12 @@ mop_simple_reader (SV *self, mop_prehashed_key_t key) } if (!(he = hv_fetch_ent((HV *)SvRV(self), prehashed_keys[key].key, 0, prehashed_keys[key].hash))) { - return &PL_sv_undef; + ST(0) = &PL_sv_undef; } - - return SvREFCNT_inc(HeVAL(he)); -} - -XS(mop_xs_simple_reader) -{ -#ifdef dVAR - dVAR; dXSARGS; -#else - dXSARGS; -#endif - - if (items != 1) { - croak("expected exactly one argument"); + else { + ST(0) = HeVAL(he); } - ST(0) = mop_simple_reader (ST(0), CvXSUBANY(cv).any_i32); - sv_2mortal(ST(0)); XSRETURN(1); } diff --git a/mop.h b/mop.h index afa9358..aa04817 100644 --- a/mop.h +++ b/mop.h @@ -52,7 +52,6 @@ inline U32 mop_prehashed_hash_for (mop_prehashed_key_t key); CvXSUBANY(cv).any_i32 = KEY_ ##key; \ } -SV *mop_simple_reader (SV *self, mop_prehashed_key_t key); XS(mop_xs_simple_reader); extern SV *mop_method_metaclass;