From: Florian Ragwitz Date: Mon, 9 Mar 2009 22:03:20 +0000 (+0100) Subject: Don't reimplement parts of get_all_package_symbols in is_class_loaded. X-Git-Tag: 0.78_01~82 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=2a2586a9ec73a7a612bb5a3ad1d8cebdbd224928;p=gitmo%2FClass-MOP.git Don't reimplement parts of get_all_package_symbols in is_class_loaded. This makes a failing test pass, but also makes is_class_loaded quite a bit slower. get_all_package_symbols needs refactoring to allow returning after it found at least one symbol that matches the filter. --- diff --git a/MOP.xs b/MOP.xs index 4fbf38f..3b1f434 100644 --- a/MOP.xs +++ b/MOP.xs @@ -352,9 +352,7 @@ is_class_loaded(klass=&PL_sv_undef) SV *klass PREINIT: HV *stash; - char *key; - I32 keylen; - SV *gv; + HV *symbols; PPCODE: if (!SvPOK(klass) || !SvCUR(klass)) { XSRETURN_NO; @@ -389,21 +387,13 @@ is_class_loaded(klass=&PL_sv_undef) } } - (void)hv_iterinit(stash); - while ((gv = hv_iternextsv(stash, &key, &keylen))) { - if (keylen <= 0) { - continue; - } - - if (key[keylen - 1] == ':' && key[keylen - 2] == ':') { - continue; - } - - if (!isGV(gv) || GvCV(gv)) { - XSRETURN_YES; - } + symbols = get_all_package_symbols(stash, TYPE_FILTER_CODE); + if (HvKEYS(symbols) > 0) { + SvREFCNT_dec((SV *)symbols); + XSRETURN_YES; } + SvREFCNT_dec((SV *)symbols); XSRETURN_NO; MODULE = Class::MOP PACKAGE = Class::MOP::Package