1
0
mirror of https://github.com/Interlisp/maiko.git synced 2026-05-03 06:49:22 +00:00

Improve the file lookup performance for {DSK} files (#498)

The directory caching for file lookup on {DSK} was disabled due to a
bug in SunOS - this is no longer relevant, so the cache can be reenabled.
This commit is contained in:
Nick Briggs
2024-04-03 21:10:54 -07:00
committed by GitHub
parent 400ccab637
commit 2e86450fad

View File

@@ -3053,10 +3053,8 @@ static int get_version_array(char *dir, char *file, FileName *varray, CurrentVAr
FileName *svarray; FileName *svarray;
DIR *dirp; DIR *dirp;
struct dirent *dp; struct dirent *dp;
/* Used in commented out code below:
int rval; int rval;
struct stat sbuf; struct stat sbuf;
*/
/* /*
* First of all, prepare a lower cased file name for the case insensitive * First of all, prepare a lower cased file name for the case insensitive
@@ -3066,20 +3064,14 @@ static int get_version_array(char *dir, char *file, FileName *varray, CurrentVAr
separate_version(lcased_file, ver, 1); separate_version(lcased_file, ver, 1);
DOWNCASE(lcased_file); DOWNCASE(lcased_file);
/* TIMEOUT(rval = stat(dir, &sbuf));
TIMEOUT(rval = stat(dir, &sbuf)); if (rval == -1) {
if (rval == -1) { *Lisp_errno = errno;
*Lisp_errno = errno; return(0);
return(0); }
}
*/
/* /*
* If the cached version array is still valid, we can return immediately. * Cache mechanism was not used because of a bug in Sun OS.
*/
/*
* Cache mechanism is not used now, because of the bug of Sun OS.
* Sometimes just after unlinking a file on a directory, the st_mtime * Sometimes just after unlinking a file on a directory, the st_mtime
* of the directory does not change. This will make Maiko believe * of the directory does not change. This will make Maiko believe
* cached version array is still valid, although it is already invalid. * cached version array is still valid, although it is already invalid.
@@ -3087,9 +3079,12 @@ static int get_version_array(char *dir, char *file, FileName *varray, CurrentVAr
*/ */
/* /*
if ((sbuf.st_mtime == cache->mtime) && strcmp(dir, cache->path) == 0 * If the cached version array is still valid, we can return immediately.
&& strcmp(lcased_file, cache->file) == 0) return(1); */
*/
if ((sbuf.st_mtime == cache->mtime) && strcmp(dir, cache->path) == 0
&& strcmp(lcased_file, cache->file) == 0) return(1);
errno = 0; errno = 0;
TIMEOUT0(dirp = opendir(dir)); TIMEOUT0(dirp = opendir(dir));
if (dirp == NULL) { if (dirp == NULL) {
@@ -3140,11 +3135,9 @@ static int get_version_array(char *dir, char *file, FileName *varray, CurrentVAr
/* /*
* Update cache information. * Update cache information.
*/ */
/* strcpy(cache->path, dir);
strcpy(cache->path, dir); strcpy(cache->file, lcased_file);
strcpy(cache->file, lcased_file); cache->mtime = sbuf.st_mtime;
cache->mtime = sbuf.st_mtime;
*/
TIMEOUT(closedir(dirp)); TIMEOUT(closedir(dirp));
return (1); return (1);
#endif /* DOS */ #endif /* DOS */