my $self = $_[0]->_get_self;
my $key = $_[1];
- #XXX What is ref() checking here?
- #YYY User may be storing a hash, in which case we do not want it run
- #YYY through the filtering system
+ # User may be storing a hash, in which case we do not want it run
+ # through the filtering system
my $value = ($self->root->{filter_store_value} && !ref($_[2]))
? $self->root->{filter_store_value}->($_[2])
: $_[2];
$self->lock( $self->LOCK_EX );
my $orig = $key;
- my $size = $self->FETCHSIZE;
+ my $size;
my $numeric_idx;
- if ( $key =~ /^-?\d+$/ ) {
+ if ( $key =~ /^\-?\d+$/ ) {
$numeric_idx = 1;
if ( $key < 0 ) {
+ $size = $self->FETCHSIZE;
$key += $size;
if ( $key < 0 ) {
die( "Modification of non-creatable array value attempted, subscript $orig" );
my $rv = $self->SUPER::STORE( $key, $value );
- if ( $numeric_idx && $rv == 2 && $orig >= $size ) {
- $self->STORESIZE( $orig + 1 );
+ if ( $numeric_idx && $rv == 2 ) {
+ $size = $self->FETCHSIZE unless defined $size;
+ if ( $orig >= $size ) {
+ $self->STORESIZE( $orig + 1 );
+ }
}
$self->unlock;
$self->lock( $self->LOCK_SH );
- if ( $key =~ /^-?\d+$/ ) {
+ if ( $key =~ /^\-?\d+$/ ) {
if ( $key < 0 ) {
$key += $self->FETCHSIZE;
unless ( $key >= 0 ) {
# DBM::Deep Test
##
use strict;
-use Test::More;
-
-my $max_keys = 4000;
-plan tests => 2;
+use Test::More tests => 2;
use_ok( 'DBM::Deep' );
##
# put/get many keys
##
+my $max_keys = 4000;
+
for ( 0 .. $max_keys ) {
$db->put( $_ => $_ * 2 );
}
my $count = -1;
for ( 0 .. $max_keys ) {
$count = $_;
- unless( $db->get( $_ ) eq $_ * 2 ) {
+ unless( $db->get( $_ ) == $_ * 2 ) {
last;
};
}