--- /dev/null
+#!./perl -w
+
+BEGIN {
+ chdir 't' if -d 't';
+ @INC = '../lib';
+ require './test.pl';
+}
+
+use strict;
+
+plan tests => 3;
+
+my %h;
+
+ok (!Internals::HvREHASH(%h), "hash doesn't start with rehash flag on");
+
+foreach (1..10) {
+ $h{"\0"x$_}++;
+}
+
+ok (!Internals::HvREHASH(%h), "10 entries doesn't trigger rehash");
+
+foreach (11..20) {
+ $h{"\0"x$_}++;
+}
+
+ok (Internals::HvREHASH(%h), "20 entries triggers rehash");
XS(XS_PerlIO_get_layers);
XS(XS_Regexp_DESTROY);
XS(XS_Internals_hash_seed);
+XS(XS_Internals_HvREHASH);
void
Perl_boot_core_UNIVERSAL(pTHX)
XS_PerlIO_get_layers, file, "*;@");
newXS("Regexp::DESTROY", XS_Regexp_DESTROY, file);
newXSproto("Internals::hash_seed",XS_Internals_hash_seed, file, "");
+ newXSproto("Internals::HvREHASH", XS_Internals_HvREHASH, file, "\\%");
}
XSRETURN_UV(PERL_HASH_SEED);
}
+XS(XS_Internals_HvREHASH) /* Subject to change */
+{
+ dXSARGS;
+ if (SvROK(ST(0))) {
+ HV *hv = (HV *) SvRV(ST(0));
+ if (items == 1 && SvTYPE(hv) == SVt_PVHV) {
+ if (HvREHASH(hv))
+ XSRETURN_YES;
+ else
+ XSRETURN_NO;
+ }
+ }
+ Perl_croak(aTHX_ "Internals::HvREHASH $hashref");
+}