diff options
author | Nicolas R <atoomic@cpan.org> | 2017-11-08 08:56:20 -0700 |
---|---|---|
committer | Nicolas R <atoomic@cpan.org> | 2017-11-08 14:43:06 -0700 |
commit | c82f4881ef5707de95df291fc9208f1c4c0e9f9e (patch) | |
tree | 3dc61a00bf17f6940e1b11973180974896e92251 /perl.c | |
parent | a500027bc99f7c703b94e5cd2a2780455307da90 (diff) | |
download | perl-c82f4881ef5707de95df291fc9208f1c4c0e9f9e.tar.gz |
Allow custom PL_strtab hash in perl_construct.
Such a patch allow PL_strtab optimizations at compile time
to statically malloc PL_strtab to an optimized size at startup.
Custom entries can then be added (after PL_hash_seed initialization)
without risking the hash to be reset by perl_construct.
Diffstat (limited to 'perl.c')
-rw-r--r-- | perl.c | 23 |
1 files changed, 14 insertions, 9 deletions
@@ -371,15 +371,20 @@ perl_construct(pTHXx) * constructing hashes */ PL_hash_seed_set= TRUE; } - /* Note that strtab is a rather special HV. Assumptions are made - about not iterating on it, and not adding tie magic to it. - It is properly deallocated in perl_destruct() */ - PL_strtab = newHV(); - - /* SHAREKEYS tells us that the hash has its keys shared with PL_strtab, - * which is not the case with PL_strtab itself */ - HvSHAREKEYS_off(PL_strtab); /* mandatory */ - hv_ksplit(PL_strtab, 1 << 11); + + /* Allow PL_strtab to be pre-initialized before calling perl_construct. + * can use a custom optimized PL_strtab hash before calling perl_construct */ + if (!PL_strtab) { + /* Note that strtab is a rather special HV. Assumptions are made + about not iterating on it, and not adding tie magic to it. + It is properly deallocated in perl_destruct() */ + PL_strtab = newHV(); + + /* SHAREKEYS tells us that the hash has its keys shared with PL_strtab, + * which is not the case with PL_strtab itself */ + HvSHAREKEYS_off(PL_strtab); /* mandatory */ + hv_ksplit(PL_strtab, 1 << 11); + } Zero(PL_sv_consts, SV_CONSTS_COUNT, SV*); |