diff options
author | Nicholas Clark <nick@ccl4.org> | 2006-03-05 17:47:23 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2006-03-05 17:47:23 +0000 |
commit | acda4c6a827049c821c192cce45f6c5299c45783 (patch) | |
tree | 02139f3a8a9ace095fd0c53c69b38f1629698203 /gv.c | |
parent | 7459f06bb5d2ce197f3e9fd16e46ba87a2ab6995 (diff) | |
download | perl-acda4c6a827049c821c192cce45f6c5299c45783.tar.gz |
Use a HEK to store the GV's name, rather than a malloc()ed string.
Saves 1 word in each GV (no more strlen), and will also save the memory
used by the string itself, as the HEK will exist already due to the
key used by the symbol table for this GV.
p4raw-id: //depot/perl@27379
Diffstat (limited to 'gv.c')
-rw-r--r-- | gv.c | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -2107,11 +2107,15 @@ void Perl_gv_name_set(pTHX_ GV *gv, const char *name, U32 len, U32 flags) { dVAR; + U32 hash; PERL_UNUSED_ARG(flags); - GvXPVGV(gv)->xgv_name = name ? savepvn(name, len) : NULL; - GvXPVGV(gv)->xgv_namelen = len; + if (len > I32_MAX) + Perl_croak(aTHX_ "panic: gv name too long (%"UVuf")", (UV) len); + + PERL_HASH(hash, name, len); + GvXPVGV(gv)->xgv_namehek = name ? share_hek(name, len, hash) : 0; } /* |