Change 34215 by [EMAIL PROTECTED] on 2008/08/22 07:00:17
In S_mro_get_linear_isa_dfs(), save copying by making a shared hash
key scalar from the key of the hash entry we've just creating.
(Currently the hash is disposed of afterwards, but soon it won't, so
having both point to the same string buffer will also save memory.)
Affected files ...
... //depot/perl/mro.c#49 edit
... //depot/perl/sv.c#1553 edit
Differences ...
==== //depot/perl/mro.c#49 (text) ====
Index: perl/mro.c
--- perl/mro.c#48~34214~ 2008-08-21 23:10:31.000000000 -0700
+++ perl/mro.c 2008-08-22 00:00:17.000000000 -0700
@@ -193,9 +193,23 @@
/* It was newly created. Steal it for our new SV, and
replace it in the hash with the "real" thing. */
SV *const val = HeVAL(he);
+ HEK *const key = HeKEY_hek(he);
HeVAL(he) = &PL_sv_undef;
- sv_setsv(val, subsv);
+ /* Save copying by making a shared hash key scalar. We
+ inline this here rather than calling Perl_newSVpvn_share
+ because we already have the scalar, and we already have
+ the hash key. */
+ assert(SvTYPE(val) == SVt_NULL);
+ sv_upgrade(val, SVt_PV);
+ SvPV_set(val, HEK_KEY(share_hek_hek(key)));
+ SvCUR_set(val, HEK_LEN(key));
+ SvREADONLY_on(val);
+ SvFAKE_on(val);
+ SvPOK_on(val);
+ if (HEK_UTF8(key))
+ SvUTF8_on(val);
+
av_push(retval, val);
}
}
==== //depot/perl/sv.c#1553 (text) ====
Index: perl/sv.c
--- perl/sv.c#1552~34213~ 2008-08-21 14:47:14.000000000 -0700
+++ perl/sv.c 2008-08-22 00:00:17.000000000 -0700
@@ -7502,6 +7502,8 @@
if (!hash)
PERL_HASH(hash, src, len);
new_SV(sv);
+ /* The logic for this is inlined in S_mro_get_linear_isa_dfs(), so if it
+ changes here, update it there too. */
sv_upgrade(sv, SVt_PV);
SvPV_set(sv, sharepvn(src, is_utf8?-len:len, hash));
SvCUR_set(sv, len);
End of Patch.