From: Nick Ing-Simmons Date: Sat, 5 Dec 1998 10:44:28 +0000 (+0000) Subject: B.xs had its own code to calculate hash() which differed from X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=cf86991c04b212c029b30807ecab507b784fd8ad;p=p5sagit%2Fp5-mst-13.2.git B.xs had its own code to calculate hash() which differed from PERL_HASH in hv.h - so all saved HV's were mangled - including %INC which meant that run-time require was re-done. Removed some debug from C.pm p4raw-id: //depot/perl@2452 --- diff --git a/ext/B/B.xs b/ext/B/B.xs index 678bbbd..3b8a7e3 100644 --- a/ext/B/B.xs +++ b/ext/B/B.xs @@ -533,10 +533,9 @@ hash(sv) char *s; STRLEN len; U32 hash = 0; - char hexhash[11]; /* must fit "0xffffffff" plus trailing \0 */ + char hexhash[19]; /* must fit "0xffffffff" plus trailing \0 */ s = SvPV(sv, len); - while (len--) - hash = hash * 33 + *s++; + PERL_HASH(hash, s, len); sprintf(hexhash, "0x%x", hash); ST(0) = sv_2mortal(newSVpv(hexhash, 0)); diff --git a/ext/B/B/C.pm b/ext/B/B/C.pm index da8c450..1c351fc 100644 --- a/ext/B/B/C.pm +++ b/ext/B/B/C.pm @@ -848,6 +848,8 @@ sub B::HV::save { my ($key, $value) = splice(@contents, 0, 2); $init->add(sprintf("\thv_store(hv, %s, %u, %s, %s);", cstring($key),length($key),$value, hash($key))); +# $init->add(sprintf("\thv_store(hv, %s, %u, %s, %s);", +# cstring($key),length($key),$value, 0)); } $init->add("}"); } @@ -1182,7 +1184,7 @@ sub should_save my $package = shift; $package =~ s/::$//; return $unused_sub_packages{$package} = 0 if ($package =~ /::::/); # skip ::::ISA::CACHE etc. - warn "Considering $package\n";#debug + # warn "Considering $package\n";#debug foreach my $u (grep($unused_sub_packages{$_},keys %unused_sub_packages)) { # If this package is a prefix to something we are saving, traverse it @@ -1193,14 +1195,14 @@ sub should_save } if (exists $unused_sub_packages{$package}) { - warn "Cached $package is ".$unused_sub_packages{$package}."\n"; + # warn "Cached $package is ".$unused_sub_packages{$package}."\n"; return $unused_sub_packages{$package} } # Omit the packages which we use (and which cause grief # because of fancy "goto &$AUTOLOAD" stuff). # XXX Surely there must be a nicer way to do this. if ($package eq "FileHandle" || $package eq "Config" || - $package eq "SelectSaver" || $package =~/^B::/) + $package eq "SelectSaver" || $package =~/^(B|IO)::/) { return $unused_sub_packages{$package} = 0; }