diff options
author | Nicholas Clark <nick@ccl4.org> | 2005-12-30 20:02:56 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2005-12-30 20:02:56 +0000 |
commit | 23579a14417118b3085c688fa8e8359c0d0a93ba (patch) | |
tree | e36bf0cb538b4a6b548bcf7c52c1530d371a8a9f /perl.c | |
parent | f9e4a5e8b675d9f0b82120fd33801982344ad4ca (diff) | |
download | perl-23579a14417118b3085c688fa8e8359c0d0a93ba.tar.gz |
Tweak S_init_main_stash so as allocate PL_curstname as a shared string
scalar, and hence avoid thrashing the shared string table for "main".
p4raw-id: //depot/perl@26544
Diffstat (limited to 'perl.c')
-rw-r--r-- | perl.c | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -3450,12 +3450,19 @@ S_init_main_stash(pTHX) GV *gv; PL_curstash = PL_defstash = newHV(); - PL_curstname = newSVpvn("main",4); + /* We know that the string "main" will be in the global shared string + table, so it's a small saving to use it rather than allocate another + 8 bytes. */ + PL_curstname = newSVpvn_share("main", 4, 0); gv = gv_fetchpv("main::",TRUE, SVt_PVHV); + /* If we hadn't caused another reference to "main" to be in the shared + string table above, then it would be worth reordering these two, + because otherwise all we do is delete "main" from it as a consequence + of the SvREFCNT_dec, only to add it again with hv_name_set */ SvREFCNT_dec(GvHV(gv)); + hv_name_set(PL_defstash, "main", 4, 0); GvHV(gv) = (HV*)SvREFCNT_inc(PL_defstash); SvREADONLY_on(gv); - hv_name_set(PL_defstash, "main", 4, 0); PL_incgv = gv_HVadd(gv_AVadd(gv_fetchpv("INC",TRUE, SVt_PVAV))); SvREFCNT_inc(PL_incgv); /* Don't allow it to be freed */ GvMULTI_on(PL_incgv); |