vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Hi, I just committed the diff. Thanks to everybody for testing. There remains one issue: in some cases, the current diff is slow, because it scans the list of previous telldir positions to avoid allocating a new entry and to implement the requirement that seekdir(loc); telldir() should return loc. The diff below (against current) should solve that. It makes use of the fact that telldirs alwas return a pos >= the current pos. So we can remember the pos last set by seekdir() or returned by telldir() and largely avoid having to scan the list all the time. -Otto Index: opendir.c ================================================== ================= RCS file: /cvs/src/lib/libc/gen/opendir.c,v retrieving revision 1.16 diff -u -p -r1.16 opendir.c --- opendir.c 1 Apr 2006 18:06:59 -0000 1.16 +++ opendir.c 1 Apr 2006 18:22:00 -0000 @@ -78,7 +78,7 @@ __opendir2(const char *name, int flags) dirp->dd_td->td_locs = NULL; dirp->dd_td->td_sz = 0; dirp->dd_td->td_loccnt = 0; - + dirp->dd_td->td_last = 0; /* * If the machine's page size is an exact multiple of DIRBLKSIZ, Index: telldir.c ================================================== ================= RCS file: /cvs/src/lib/libc/gen/telldir.c,v retrieving revision 1.8 diff -u -p -r1.8 telldir.c --- telldir.c 1 Apr 2006 18:06:59 -0000 1.8 +++ telldir.c 1 Apr 2006 18:22:00 -0000 @@ -42,14 +42,18 @@ long telldir(DIR *dirp) { - long i = 0; - struct ddloc *lp = dirp->dd_td->td_locs; + long i = dirp->dd_td->td_last; + struct ddloc *lp; + + lp = &dirp->dd_td->td_locs[i]; /* return previous telldir, if there */ for (; i < dirp->dd_td->td_loccnt; i++, lp++) { if (lp->loc_seek == dirp->dd_seek && - lp->loc_loc == dirp->dd_loc) + lp->loc_loc == dirp->dd_loc) { + dirp->dd_td->td_last = i; return (i); + } } if (dirp->dd_td->td_loccnt == dirp->dd_td->td_sz) { @@ -65,6 +69,7 @@ telldir(DIR *dirp) dirp->dd_td->td_loccnt++; lp->loc_seek = dirp->dd_seek; lp->loc_loc = dirp->dd_loc; + dirp->dd_td->td_last = i; return (i); } @@ -81,6 +86,7 @@ __seekdir(DIR *dirp, long loc) if (loc < 0 || loc >= dirp->dd_td->td_loccnt) return; lp = &dirp->dd_td->td_locs[loc]; + dirp->dd_td->td_last = loc; if (lp->loc_loc == dirp->dd_loc && lp->loc_seek == dirp->dd_seek) return; (void) lseek(dirp->dd_fd, (off_t)lp->loc_seek, SEEK_SET); Index: telldir.h ================================================== ================= RCS file: /cvs/src/lib/libc/gen/telldir.h,v retrieving revision 1.1 diff -u -p -r1.1 telldir.h --- telldir.h 1 Apr 2006 18:06:59 -0000 1.1 +++ telldir.h 1 Apr 2006 18:22:00 -0000 @@ -55,6 +55,7 @@ struct _telldir { struct ddloc *td_locs; /* locations */ size_t td_sz; /* size of locations */ long td_loccnt; /* index of entry for sequential readdir's */ + long td_last; /* last tell/seekdir */ }; void __seekdir(DIR *, long); |