Skip to content
  • Richard Gobeille's avatar
    engine: implement buildvfs_exists() using GetFileAttributes() on Windows and... · 26bb86c1
    Richard Gobeille authored
    engine: implement buildvfs_exists() using GetFileAttributes() on Windows and stat() elsewhere, FORCE_INLINE some stuff in vfs.h
    
    The rationale behind this change is that I was profiling CPU use during loads of particularly heavy .def files (10000+ items) and discovered an inappropriate amount of CPU time was being spent inside access(). So, I did some research and found several cases where people on stackoverflow etc had asked what the fastest method of determining whether or not a file exists was, with the results of several benchmarks being given as answers. GetFileAttributes() seemed to win on Windows and stat() seemed to win on Linux, and I did not see any results where access() was a serious contender when included in the spread of tested functions, with the best I saw being 1100-something nanoseconds for access() and 800-something for stat().
    
    This whole thing would be faster if we just read in the entire directory index and matched files against it ourselves with just the few API calls involved with retrieving the index, but access to uncooked data littered across a directory tree isn't really something I give a shit about optimizing further at the moment.
    26bb86c1