[Issue 19484] New: Fix it so that DirEntry on POSIX only calls lstat once
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Dec 13 23:37:32 UTC 2018
https://issues.dlang.org/show_bug.cgi?id=19484
Issue ID: 19484
Summary: Fix it so that DirEntry on POSIX only calls lstat once
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: enhancement
Priority: P1
Component: phobos
Assignee: nobody at puremagic.com
Reporter: issues.dlang at jmdavisProg.com
On POSIX, DirEntry's constructor calls exists to verify that the file exists
and then throws if it doesn't - which makes perfect sense until you look at
what exists does. exists calls lstat, which is fine in and of itself, but
calling exists means that that information is thrown away, whereas DirEntry
then later calls lstat again when certain functions are called. It has the
_didLStat member to keep track of whether it's called lstat yet, so it avoids
calling it multiple times when the properties on it are used which require it,
but it would be more efficient to just call lstat directly in the constructor
and always save the result. If lstat fails, the exception can be thrown like it
is now, but by checking the result of lstat directly rather than using exists,
we remove the need for _didLStat, and we make it so that lstat is always called
exactly once instead of being called once if the information from lstat isn't
needed later or twice if it is.
--
More information about the Digitalmars-d-bugs
mailing list