summaryrefslogtreecommitdiff
path: root/perl.c
diff options
context:
space:
mode:
authorNicolas R <atoomic@cpan.org>2017-11-08 08:56:20 -0700
committerNicolas R <atoomic@cpan.org>2017-11-08 14:43:06 -0700
commitc82f4881ef5707de95df291fc9208f1c4c0e9f9e (patch)
tree3dc61a00bf17f6940e1b11973180974896e92251 /perl.c
parenta500027bc99f7c703b94e5cd2a2780455307da90 (diff)
downloadperl-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.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/perl.c b/perl.c
index 2d04271b9f..454cc756ba 100644
--- a/perl.c
+++ b/perl.c
@@ -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*);