Optimization: First broke out all the classes that were in Engine.pm so that I can...
[dbsrgits/DBM-Deep.git] / lib / DBM / Deep / Array.pm
index 3b0c8bd..73babc5 100644 (file)
@@ -3,9 +3,7 @@ package DBM::Deep::Array;
 use 5.006_000;
 
 use strict;
-use warnings;
-
-our $VERSION = q(1.0009);
+use warnings FATAL => 'all';
 
 # This is to allow DBM::Deep::Array to handle negative indices on
 # its own. Otherwise, Perl would intercept the call to negative
@@ -269,13 +267,16 @@ sub SHIFT {
         return;
     }
 
-    my $content = $self->FETCH( 0 );
+    my $content = $self->DELETE( 0 );
 
-    for (my $i = 0; $i < $length - 1; $i++) {
-        $self->_move_value( $i+1, $i );
-    }
+    # Unless the deletion above has cleared the array ...
+    if ( $length > 1 ) {
+        for (my $i = 0; $i < $length - 1; $i++) {
+            $self->_move_value( $i+1, $i );
+        }
 
-    $self->DELETE( $length - 1 );
+        $self->DELETE( $length - 1 );
+    }
 
     $self->unlock;
 
@@ -388,8 +389,7 @@ sub _copy_node {
 
     my $length = $self->length();
     for (my $index = 0; $index < $length; $index++) {
-        my $value = $self->get($index);
-        $self->_copy_value( \$db_temp->[$index], $value );
+        $self->_copy_value( \$db_temp->[$index], $self->get($index) );
     }
 
     return 1;