From: Brandon L Black Date: Mon, 16 Apr 2007 02:00:47 +0000 (+0000) Subject: still working on cache stuff X-Git-Tag: 0.02~16 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=6bf46d18464d8a54364f5f7d6b83647fb76c0512;p=gitmo%2FClass-C3-XS.git still working on cache stuff --- diff --git a/lib/Class/C3/XS.xs b/lib/Class/C3/XS.xs index 016cbcc..bdf3fa7 100644 --- a/lib/Class/C3/XS.xs +++ b/lib/Class/C3/XS.xs @@ -32,10 +32,14 @@ __mro_linear_isa_c3(pTHX_ HV* stash, HV* cache, I32 level) stashname); if(!cache) { - cache = newHV(); + cache = sv_2mortal(newHV()); } else { - /* XXX return cached entry for stashname if available */ +/* + SV** cache_entry = hv_fetch(cache, stashname, stashname_len, 0); + if(cache_entry) + return (AV*)SvREFCNT_inc(*cache_entry); +*/ } /* not in cache, make a new one */ @@ -139,8 +143,8 @@ __mro_linear_isa_c3(pTHX_ HV* stash, HV* cache, I32 level) SvREADONLY_on(retval); SvREFCNT_inc(retval); /* for cache storage */ - SvREFCNT_inc(retval); /* for return to caller */ - /* XXX store in cache storage */ + SvREFCNT_inc(retval); /* for return */ + /* hv_store(cache, stashname, stashname_len, (SV*)retval, 0); */ return retval; } @@ -277,8 +281,7 @@ __nextcan(pTHX_ SV* self, I32 throw_nomethod) stashname_len = subname - fq_subname - 2; stashname = sv_2mortal(newSVpvn(fq_subname, stashname_len)); - linear_av = __mro_linear_isa_c3(selfstash, NULL, 0); /* has ourselves at the top of the list */ - sv_2mortal((SV*)linear_av); + linear_av = (AV*)sv_2mortal((SV*)__mro_linear_isa_c3(selfstash, NULL, 0)); linear_svp = AvARRAY(linear_av); items = AvFILLp(linear_av) + 1; @@ -374,7 +377,6 @@ XS(XS_Class_C3_XS_calculateMRO) res = (AV*)sv_2mortal((SV*)__mro_linear_isa_c3(class_stash, cache, 0)); - res_items = ret_items = AvFILLp(res) + 1; res_ptr = AvARRAY(res);