Anonymous avatar Anonymous committed 26cf38e

next_obj() refactoring.

Comments (0)

Files changed (2)

     by eval ""'ing it because it contains many conditions that depend
     on instance-wide and constant parameters.
     - Cleanup: moved some POD'ed out functions to under rejects/ .
+    - Optimization: renamed _calc_next_obj() to next_obj(), as next_obj()
+    just called it directly. Cleaned up the rest of the logic in next_obj().
 
 0.1.7 - Thu Jan 15 16:09:49 IST 2009
     - Fixed the check-for-link and for directory semantics on Windows

lib/File/Find/Object.pm

     return bless $ret, "File::Find::Object::Result";
 }
 
-sub _calc_next_obj {
-    my ($self) = @_;
-    while (1) {
-        if ($self->_process_current())
-        {
-            return $self->item_obj();
-        }
-        if(!$self->_master_move_to_next) {
-            if ($self->_me_die())
-            {
-                $self->item_obj(undef());
-                return undef();
-            }
-        }
-    }
-}
-
 sub next_obj {
     my $self = shift;
 
-    return $self->_calc_next_obj();
+    until (     $self->_process_current 
+            || ((!$self->_master_move_to_next())
+               && $self->_me_die())
+            )
+    {
+        # Do nothing
+    }
+
+    return $self->item_obj();
 }
 
 sub next {
 }
 
 sub _me_die_t {
+    shift->item_obj(undef());
+
     return 1;
 }
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.