In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/5322d43eec5f30a4b16c8bac6ae324f91deab5f5?hp=6b3df22776523c7e117a080b445b166b31464123>
- Log ----------------------------------------------------------------- commit 5322d43eec5f30a4b16c8bac6ae324f91deab5f5 Author: Nicholas Clark <[email protected]> Date: Tue Mar 8 20:14:11 2011 +0000 Add PERL_NO_GET_CONTEXT to NamedCapture.xs M ext/Tie-Hash-NamedCapture/NamedCapture.xs commit 63f281fa1e421520fab564bf3362bf3b7082b2c7 Author: Nicholas Clark <[email protected]> Date: Tue Mar 8 20:01:46 2011 +0000 Tweak Tie::Hash::NamedCapture's BOOT code - get the stash from the CV. This will result in less work than using newSVrv(), as the character string passed to that is used to walk the symbol table to find the stash. We already have a fast way to get to the stash - via the CV's GV. So use that directly. M ext/Tie-Hash-NamedCapture/NamedCapture.xs ----------------------------------------------------------------------- Summary of changes: ext/Tie-Hash-NamedCapture/NamedCapture.xs | 14 ++++++++++---- 1 files changed, 10 insertions(+), 4 deletions(-) diff --git a/ext/Tie-Hash-NamedCapture/NamedCapture.xs b/ext/Tie-Hash-NamedCapture/NamedCapture.xs index 459a998..8a767c5 100644 --- a/ext/Tie-Hash-NamedCapture/NamedCapture.xs +++ b/ext/Tie-Hash-NamedCapture/NamedCapture.xs @@ -1,3 +1,4 @@ +#define PERL_NO_GET_CONTEXT /* we want efficiency */ #include "EXTERN.h" #include "perl.h" #include "XSUB.h" @@ -16,13 +17,15 @@ #define SCALAR_ALIAS (RXapif_SCALAR | (1 << EXPECT_SHIFT)) static -tie_it(pTHX_ const char name, UV flag) +tie_it(pTHX_ const char name, UV flag, HV *const stash) { GV *const gv = gv_fetchpvn(&name, 1, GV_ADDMULTI|GV_NOTQUAL, SVt_PVHV); HV *const hv = GvHV(gv); SV *rv = newSV_type(SVt_RV); - sv_setuv(newSVrv(rv, "Tie::Hash::NamedCapture"), flag); + SvRV_set(rv, newSVuv(flag)); + SvROK_on(rv); + sv_bless(rv, stash); sv_unmagic((SV *)hv, PERL_MAGIC_tied); sv_magic((SV *)hv, rv, PERL_MAGIC_tied, NULL, 0); @@ -33,8 +36,11 @@ MODULE = Tie::Hash::NamedCapture PACKAGE = Tie::Hash::NamedCapture PROTOTYPES: DISABLE BOOT: - tie_it(aTHX_ '-', RXapif_ALL); - tie_it(aTHX_ '+', RXapif_ONE); + { + HV *const stash = GvSTASH(CvGV(cv)); + tie_it(aTHX_ '-', RXapif_ALL, stash); + tie_it(aTHX_ '+', RXapif_ONE, stash); + } SV * TIEHASH(package, ...) -- Perl5 Master Repository
