diff options
author | phk <phk@FreeBSD.org> | 1996-05-02 08:43:05 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 1996-05-02 08:43:05 +0000 |
commit | 37811d9fc0db7d38415e2e6a6e4edf1fc0cba972 (patch) | |
tree | f3e5cad6b9610b6b082996ce7e9732c47feed41e /lib/libc/gen/opendir.c | |
parent | 4622dbc30bb429e73df5bc451c81d74762753a53 (diff) | |
download | FreeBSD-src-37811d9fc0db7d38415e2e6a6e4edf1fc0cba972.zip FreeBSD-src-37811d9fc0db7d38415e2e6a6e4edf1fc0cba972.tar.gz |
Cache the result of getpagesize() so we only make one syscall.
Use getpagesize instead of CLBYTES.
Diffstat (limited to 'lib/libc/gen/opendir.c')
-rw-r--r-- | lib/libc/gen/opendir.c | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/lib/libc/gen/opendir.c b/lib/libc/gen/opendir.c index 8cba9cf..a3db45b 100644 --- a/lib/libc/gen/opendir.c +++ b/lib/libc/gen/opendir.c @@ -79,18 +79,13 @@ opendir(name) (dirp = malloc(sizeof(DIR))) == NULL) goto fail; /* - * If CLBYTES is an exact multiple of DIRBLKSIZ, use a CLBYTES - * buffer that it cluster boundary aligned. - * Hopefully this can be a big win someday by allowing page trades - * to user space to be done by getdirentries() + * Use the system page size if that is a multiple of DIRBLKSIZ + * this could speed things up in some cases we hope */ - if ((CLBYTES % DIRBLKSIZ) == 0) { - dirp->dd_buf = malloc(CLBYTES); - dirp->dd_len = CLBYTES; - } else { - dirp->dd_buf = malloc(DIRBLKSIZ); + dirp->dd_len = getpagesize(); + if ((dirp->dd_len % DIRBLKSIZ) != 0) dirp->dd_len = DIRBLKSIZ; - } + dirp->dd_buf = malloc(dirp->dd_len); if (dirp->dd_buf == NULL) goto fail; dirp->dd_fd = fd; |