🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.unix.shell
Article #1491

Re: Leaf directories (Re: Why is find so slow)

#1491
From: Larry Wall
Date: Sat, 13 Oct 1990 21:07
26 lines
1348 bytes
In article <26981@mimsy.umd.edu> chris@mimsy.umd.edu (Chris Torek) writes:
: In article <F&0u96p2@cs.psu.edu> flee@guardian.cs.psu.edu (Felix Lee) writes:
: >Leaf directories are directories with no subdirectories.  A leaf
: >directory has a link count <= 2.
: 
: It is easier than that (and harder than this, which leaves out error
: checking):
: 
: 	d = opendir(dir);
: 	fstat(dirfd(d), &st);
: 	nsubdirs = st.st_nlink - 2;
: 	while ((dp = readdir(d)) != NULL) {
: 		if (need_stat_anyway || nsubdirs > 0) {
: 			get_stat(dir, dp->d_name, &st);
: 			if (S_ISDIR(st.st_mode))
: 				nsubdirs--;
: 		}
: 		...
: 	}

If find is done this way, it would behoove us to sort subdirectories
before filenames in each directory so that nsubdirs goes to 0 as soon
as possible.

Larry Wall
lwall@jpl-devvax.jpl.nasa.gov
Technical Details
Message-ID: <9959@jpl-devvax.JPL.NASA.GOV>
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!know!sdd.hp.com!elroy.jpl.nasa.gov!jpl-devvax!lwall
References: <F&gya5o2@cs.psu.edu> <15052@hydra.gatech.EDU> <F&0u96p2@cs.psu.edu> <26981@mimsy.umd.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!know!sdd.hp.com!elroy.jpl.nasa.gov!jpl-devvax!lwall
From: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall)
Newsgroups: comp.unix.shell
Subject: Re: Leaf directories (Re: Why is find so slow)
Message-ID: <9959@jpl-devvax.JPL.NASA.GOV>
Date: 13 Oct 90 21:07:53 GMT
References: <F&gya5o2@cs.psu.edu> <15052@hydra.gatech.EDU> <F&0u96p2@cs.psu.edu> <26981@mimsy.umd.edu>
Reply-To: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall)
Organization: Jet Propulsion Laboratory, Pasadena, CA
Lines: 26