in reply to Re: Re: opendir in file find
in thread opendir in file find

You can save a little overhead by reusing the stat buffer using the magical filehandle '_',

Yes and no. You can do that if you first disable File::Find's overeager "optimization" via:

$File::Find::dont_use_nlink= 1;
If you don't do that first, then File::Find will skip doing lstat in some cases and your use of _ will give you stale data (data for the wrong file) in those cases.

I'd much rather you have to request this optimization when you want it (which, on some file systems, can speed up Find operations where you don't care about anything but the file name), but p5p seems pretty violently against making this "optimization" opt-in instead of opt-out.

                - tye

Replies are listed 'Best First'.
Re: Re^3: opendir in file find (anti-optimization effects)
by BrowserUk (Patriarch) on Jul 25, 2003 at 18:11 UTC

    Thanks for the heads-up on this. I don't make a lot of use of the module, but that is worth noting.

    Where does that sit with this statement in the 5.8 pod though?

    It is guaranteed that an lstat has been called before the user's wanted() function is called. This enables fast file checks involving _.

    Examine what is said, not who speaks.
    "Efficiency is intelligent laziness." -David Dunham
    "When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller

      The sentence directly before what you quoted is:

      If either *follow* or *follow_fast* is in effect:
      which is what makes the statement you quoted correct.

      It would be nice if the module also documented that "don't use nlink" also had this effect (and made it as easy to not use nlink as it is to specify 'follow' or 'follow_fast').

      But I won't submit such a patch after the reaction I got the last few times I've had the gal to criticize the nlink hack"optimization" to p5p. q-:

                      - tye

        So it does:)

        With the strange way the paragraph I quoted is formatted in the HTML version of the POD, I'd never noticed the pre-qualification tucked away at the end of that rather long and uninteresting (to a user of systems that basically don't use symbolic links) sentance.


        Examine what is said, not who speaks.
        "Efficiency is intelligent laziness." -David Dunham
        "When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller