Commits

shl...@6f433eb9-a002-0410-945b-ee5462c261ee  committed b13ced9

Refactoring: extracted the _find_ancestor_with_same_st method.

  • Participants
  • Parent commits 6400004

Comments (0)

Files changed (1)

File lib/File/Find/Object.pm

     return 1;
 }
 
+sub _find_ancestor_with_same_st {
+    my $self = shift;
+    my $st = shift;
+
+    my $ptr = $self->_current_father;
+    my $rc;
+
+    while($ptr) {
+        if ($ptr->_is_same_inode($st)) {
+            return $ptr;
+        }
+    }
+    continue {
+        $ptr = $self->_father($ptr);
+    }
+    return;
+}
+
 sub _non_top__check_subdir_helper {
     my $self = shift;
     my $st = shift;
         return 0;
     }
 
-    my $ptr = $self->_current_father;
-    my $rc;
-
-    while($ptr) {
-        if ($ptr->_is_same_inode($st)) {
-            $rc = 1;
-            last;
-        }
-    }
-    continue {
-        $ptr = $self->_father($ptr);
-    }
-
-    if ($rc) {
+    if (my $ptr = $self->_find_ancestor_with_same_st($st)) {
         printf(STDERR "Avoid loop " . $ptr->_dir_as_string . " => %s\n",
             $self->_current_path());
         return 0;
     }
+
     return 1;
 }