From: rkinyon@cpan.org Date: Sun, 15 Jun 2008 18:44:36 +0000 (+0000) Subject: Converted DBM::Deep::Engine::Sector::Scalar to using a string in _init() X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=64d41c49decb86f94b581603e906c20d8450bef7;p=dbsrgits%2FDBM-Deep.git Converted DBM::Deep::Engine::Sector::Scalar to using a string in _init() git-svn-id: http://svn.ali.as/cpan/trunk/DBM-Deep@3575 88f4d9cd-8a04-0410-9d60-8f63309c3137 --- diff --git a/lib/DBM/Deep/Engine/Sector/Scalar.pm b/lib/DBM/Deep/Engine/Sector/Scalar.pm index a28e88b..8984b94 100644 --- a/lib/DBM/Deep/Engine/Sector/Scalar.pm +++ b/lib/DBM/Deep/Engine/Sector/Scalar.pm @@ -32,16 +32,17 @@ sub _init { my $engine = $self->engine; unless ( $self->offset ) { - my $data_section = $self->size - $self->base_size - $engine->byte_size - 1; - $self->{offset} = $engine->_request_data_sector( $self->size ); - my $data = delete $self->{data}; my $dlen = length $data; - my $continue = 1; + + my $data_section = $self->size - $self->base_size - $engine->byte_size - 1; + + + my $curr_offset = $self->offset; + my $continue = 1; while ( $continue ) { - my $next_offset = 0; my ($leftover, $this_len, $chunk); @@ -62,15 +63,18 @@ sub _init { $continue = 0; } - $engine->storage->print_at( $curr_offset, $self->type ); # Sector type - # Skip staleness - $engine->storage->print_at( $curr_offset + $self->base_size, - pack( $engine->StP($engine->byte_size), $next_offset ), # Chain loc - pack( $engine->StP(1), $this_len ), # Data length - $chunk, # Data to be stored in this sector - chr(0) x $leftover, # Zero-fill the rest + my $string = chr(0) x $self->size; + substr( $string, 0, 1, $self->type ); + substr( $string, $self->base_size, $engine->byte_size + 1, + pack( $engine->StP($engine->byte_size), $next_offset ) # Chain loc + . pack( $engine->StP(1), $this_len ), # Data length + ); + substr( $string, $self->base_size + $engine->byte_size + 1, $this_len, + $chunk, ); + $engine->storage->print_at( $curr_offset, $string ); + $curr_offset = $next_offset; }