From: Florian Ragwitz Date: Tue, 30 Jun 2009 18:00:47 +0000 (+0200) Subject: Return an empty method map instead of undef for non-existant stashes. X-Git-Tag: 0.89~22 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=bf49623df9d87adf0a7c907d8e85b5d6e3859221;p=gitmo%2FClass-MOP.git Return an empty method map instead of undef for non-existant stashes. --- diff --git a/xs/Class.xs b/xs/Class.xs index 709953e..0b8a968 100644 --- a/xs/Class.xs +++ b/xs/Class.xs @@ -91,14 +91,16 @@ get_method_map(self) UV current; SV *cache_flag; SV *map_ref; - INIT: + PPCODE: if (!stash) { - XSRETURN_EMPTY; + mXPUSHs(newRV_noinc((SV *)newHV())); + return; } + current = mop_check_package_cache_flag(aTHX_ stash); cache_flag = HeVAL( hv_fetch_ent(obj, KEY_FOR(package_cache_flag), TRUE, HASH_FOR(package_cache_flag))); map_ref = HeVAL( hv_fetch_ent(obj, KEY_FOR(methods), TRUE, HASH_FOR(methods))); - PPCODE: + /* in $self->{methods} does not yet exist (or got deleted) */ if ( !SvROK(map_ref) || SvTYPE(SvRV(map_ref)) != SVt_PVHV ) { SV *new_map_ref = newRV_noinc((SV *)newHV());