From: gfx Date: Sun, 1 Nov 2009 03:39:19 +0000 (+0900) Subject: Tidy and simplify mouse_attr_get() X-Git-Tag: 0.40_04~1 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=8fa5f9b88713d63f037557b55d8f0811f0531f21;p=gitmo%2FMouse.git Tidy and simplify mouse_attr_get() --- diff --git a/xs-src/MouseAccessor.xs b/xs-src/MouseAccessor.xs index dd89a00..6edbaea 100644 --- a/xs-src/MouseAccessor.xs +++ b/xs-src/MouseAccessor.xs @@ -250,25 +250,21 @@ mouse_attr_get(pTHX_ SV* const self, MAGIC* const mg){ /* check_lazy */ if( !value && flags & MOUSEf_ATTR_IS_LAZY ){ - AV* const xa = MOUSE_mg_xa(mg); + AV* const xa = MOUSE_mg_xa(mg); SV* const attr = MOUSE_xa_attribute(xa); - /* get default value by $attr->default or $attr->builder */ - if(flags & MOUSEf_ATTR_HAS_DEFAULT){ + /* get default value by $attr->builder or $attr->default */ + if(flags & MOUSEf_ATTR_HAS_BUILDER){ + SV* const builder = mcall0s(attr, "builder"); + value = mcall0(self, builder); + } + else { value = mcall0s(attr, "default"); if(SvROK(value) && SvTYPE(SvRV(value)) == SVt_PVCV){ value = mcall0(self, value); } } - else if(flags & MOUSEf_ATTR_HAS_BUILDER){ - SV* const builder = mcall0s(attr, "builder"); - value = mcall0(self, builder); - } - - if(!value){ - value = sv_newmortal(); - } /* apply coerce and type constraint */ if(flags & MOUSEf_ATTR_HAS_TC){