Commits

Anonymous committed f5acf04

Now caching _current() as _dir_stack()->[-1] explicitly.

Comments (0)

Files changed (2)

     - Refactoring - made the first ::PathTop component the first element
     in _dir_stack() so we won't need to keep in a distinct reference. All
     the other elements moved 1 level down the stack.
+    - Optimization - now caching $top->_dir_stack()->[-1] into 
+    $top->_current() as an accessor.
 
 0.1.5 - Sat Jan  3 17:17:31 IST 2009
     - Unified the two calls to stat() (and several calls to other file

lib/File/Find/Object.pm

         (map { $_ => $_ } 
         (qw(
             _curr_comps
+            _current
             _curr_path
             _def_actions
             _dir_stack
             item_obj
+            _target_index
             _targets
-            _target_index
             _top_stat
             ), 
             @{__PACKAGE__->_get_options_ids()}
     $tree->_calc_default_actions();
 
     push @{$tree->_dir_stack()},
-        File::Find::Object::TopPath->new($tree)
+        $tree->_current(File::Find::Object::TopPath->new($tree))
         ;
 
     $tree->_last_dir_scanned(undef);
 #    printf STDERR "destroy `%s'\n", $self->_dir_as_string || "--";
 #}
 
-sub _current
-{
-    my $self = shift;
-
-    return $self->_dir_stack->[-1];
-}
-
 =begin Removed
 
 # We're removing this because it's no longer used, but may be used in the
     if ($father->idx == 0)
     {
         splice(@$st, 1);
+        $self->_current($st->[-1]);
         delete($self->{_st});
     }
     else
     {
         splice(@$st, $father->idx()+1);
         splice(@{$self->_curr_comps()}, $father->idx()+1);
+        $self->_current($st->[-1]);
         
         # If depth is false, then we no longer need the _curr_path
         # of the directories above the previously-set value, because we 
         return "SKIP";
 
     push @{$self->_dir_stack()}, 
-        File::Find::Object::DeepPath->new(
-            $self,
-            $self->_current(),
-            scalar(@{$self->_dir_stack()})
+        $self->_current(
+            File::Find::Object::DeepPath->new(
+                $self,
+                $self->_current(),
+                scalar(@{$self->_dir_stack()})
+            )
         );
 
     $self->{_st} = 1;