From: jhuckaby Date: Thu, 23 Feb 2006 08:11:08 +0000 (+0000) Subject: Fixed autobless bug with re-blessing into class with longer name X-Git-Tag: 0-97~12 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=00646d6a7b5df806b3b1a2fad1dd815f1bb1c268;p=dbsrgits%2FDBM-Deep.git Fixed autobless bug with re-blessing into class with longer name --- diff --git a/lib/DBM/Deep.pm b/lib/DBM/Deep.pm index 6c332cb..e9f89cf 100644 --- a/lib/DBM/Deep.pm +++ b/lib/DBM/Deep.pm @@ -439,7 +439,18 @@ sub _add_bucket { ## my $actual_length; my $r = Scalar::Util::reftype( $value ) || ''; - if ( $r eq 'HASH' || $r eq 'ARRAY' ) { $actual_length = $INDEX_SIZE; } + if ( $r eq 'HASH' || $r eq 'ARRAY' ) { + $actual_length = $INDEX_SIZE; + + # if autobless is enabled, must also take into consideration + # the class name, as it is stored along with key/value. + if ( $self->root->{autobless} ) { + my $value_class = Scalar::Util::blessed($value); + if ( defined $value_class && $value_class ne 'DBM::Deep' ) { + $actual_length += length($value_class); + } + } # autobless + } else { $actual_length = length($value); } if ($actual_length <= $size) {