Commits

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

Optimization converted to List::Util::first.

  • Participants
  • Parent commits 4f49967

Comments (0)

Files changed (2)

     if they are directories. Now added a test for that.
         - Fixed t/01ffo.t to check for the warning.
         - Also see: http://www.nntp.perl.org/group/perl.perl5.porters/2009/01/msg143399.html
+    - Small optimization: converted a loop with:
+      while($ptr) { ... } continue { $ptr = $self->_father($ptr); }
+      to List::Util::first.
 
 0.1.6 - Fri Jan  9 17:49:01 IST 2009
     - Converted the accessor generator to Class::XSAccessor instead

File lib/File/Find/Object.pm

 use File::Find::Object::Result;
 
 use Fcntl ':mode';
+use List::Util ();
 
 sub _get_options_ids
 {
 sub _find_ancestor_with_same_inode {
     my $self = shift;
 
-    my $ptr = $self->_current_father;
+    my $s = $self->_top_stat();
+    my $stack = $self->_dir_stack();
 
-    while($ptr) {
-        if ($ptr->_is_same_inode($self->_top_stat())) {
-            return $ptr;
-        }
-    }
-    continue {
-        $ptr = $self->_father($ptr);
-    }
-
-    return;
+    return List::Util::first { $_->_is_same_inode($s) } @{$stack}[0 .. $#$stack-1];
 }
 
 sub _warn_about_loop