Commits

Anonymous committed 22bfea1

Refactoring: top/non_top for _check_subdir.

Comments (0)

Files changed (1)

lib/File/Find/Object.pm

     return;
 }
 
-__PACKAGE__->_top_it([qw(_current _me_die)]);
+__PACKAGE__->_top_it([qw(_current _me_die _check_subdir_helper)]);
 
 use Carp;
 
 {
     my $self = shift;
 
-    my $current = $self->_current();
-
     # If current is not a directory always return 0, because we may
     # be asked to traverse single-files.
     my @st = stat($self->_current_path());
     {
         return 0;
     }
+    else
+    {
+        return $self->_check_subdir_helper(\@st);
+    }
+}
 
-    if ($self->_is_top())
-    {
-        return 1;
-    }
+sub _top__check_subdir_helper {
+    return 1;
+}
+
+sub _non_top__check_subdir_helper {
+    my $self = shift;
+    my $st = shift;
+
+    my $current = $self->_current();
+
     if (-l $self->_current_path() && !$self->followlink())
     {
         return 0;
     }
-    if ($st[0] != $self->_father($current)->dev() && $self->nocrossfs())
+    if ($st->[0] != $self->_father($current)->dev() && $self->nocrossfs())
     {
         return 0;
     }
     my $ptr = $current; my $rc;
     while($self->_father($ptr)) {
-        if($self->_father($ptr)->inode() == $st[1] && $self->_father($ptr) == $st[0]) {
+        if($self->_father($ptr)->inode() == $st->[1] && $self->_father($ptr) == $st->[0]) {
             $rc = 1;
             last;
         }