diff --git a/gv.c b/gv.c index 8b43d91ef836..47793eff2a45 100644 --- a/gv.c +++ b/gv.c @@ -1313,8 +1313,8 @@ The most important of which are probably GV_ADD and SVf_UTF8. =cut */ -HV* -Perl_gv_stashpvn(pTHX_ const char *name, U32 namelen, I32 flags) +PERL_STATIC_INLINE HV* +S_stashpvn(pTHX_ const char *name, U32 namelen, I32 flags) { char smallbuf[128]; char *tmpbuf; @@ -1351,6 +1351,25 @@ Perl_gv_stashpvn(pTHX_ const char *name, U32 namelen, I32 flags) return stash; } +HV* +Perl_gv_stashpvn(pTHX_ const char *name, U32 namelen, I32 flags) +{ + HV* stash; + const HE* const he = (const HE *)hv_common( + PL_stashcache, NULL, name, namelen, + (flags & SVf_UTF8) ? HVhek_UTF8 : 0, 0, NULL, 0 + ); + if (he) return INT2PTR(HV*,SvIVX(HeVAL(he))); + + stash = S_stashpvn(aTHX_ name, namelen, flags); + if (stash && namelen) { + SV* const ref = newSViv(PTR2IV(stash)); + hv_store(PL_stashcache, name, + (flags & SVf_UTF8) ? -(I32)namelen : (I32)namelen, ref, 0); + } + return stash; +} + /* =for apidoc gv_stashsv