From: Nicholas Clark Date: Sun, 28 Dec 2008 09:50:21 +0000 (+0000) Subject: Also test Perl_hv_common() and pre-computed hashes for SV keys. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=58ca560a9acfccd7c196fdebef1d0c50c1b4b155;p=p5sagit%2Fp5-mst-13.2.git Also test Perl_hv_common() and pre-computed hashes for SV keys. --- diff --git a/ext/XS/APItest/APItest.xs b/ext/XS/APItest/APItest.xs index e63d804..7e7f78b 100644 --- a/ext/XS/APItest/APItest.xs +++ b/ext/XS/APItest/APItest.xs @@ -455,6 +455,11 @@ common(params) if ((svp = hv_fetchs(params, "hash_pv", 0))) { PERL_HASH(hash, key, klen); } + if ((svp = hv_fetchs(params, "hash_sv", 0))) { + STRLEN len; + const char *const p = SvPV(keysv, len); + PERL_HASH(hash, p, len); + } result = (HE *)hv_common(hv, keysv, key, klen, flags, action, val, hash); if (!result) { diff --git a/ext/XS/APItest/t/hash.t b/ext/XS/APItest/t/hash.t index 47d4437..cb8b26b 100644 --- a/ext/XS/APItest/t/hash.t +++ b/ext/XS/APItest/t/hash.t @@ -156,17 +156,22 @@ if ($] > 5.009) { my $as_bytes = "\243"; foreach my $key ('N', $as_bytes, $as_utf8, "\x{2623}") { my $ord = ord $key; - foreach my $hash_pv (0, 1) { - my %hash; - is (XS::APItest::Hash::common({hv => \%hash, keypv => $key, - val => $ord, hash_pv => $hash_pv, - action => - XS::APItest::HV_FETCH_ISSTORE}), - $ord, "store $ord \$hash_pv = $hash_pv"); - is_deeply ([each %hash], [$key, $ord], "First key read is good"); - is_deeply ([each %hash], [], "No second key good"); - - is ($hash{$key}, $ord, "Direct hash read finds $ord"); + foreach my $hash_it (0, 1) { + foreach my $what (qw(pv sv)) { + my %hash; + is (XS::APItest::Hash::common({hv => \%hash, + "key$what" => $key, + val => $ord, + "hash_$what" => $hash_it, + action => + XS::APItest::HV_FETCH_ISSTORE}), + $ord, "store $ord with $what \$hash_it = $hash_it"); + is_deeply ([each %hash], [$key, $ord], + "First key read is good"); + is_deeply ([each %hash], [], "No second key good"); + + is ($hash{$key}, $ord, "Direct hash read finds $ord"); + } } } }