minor perf optimization: remove this loop on macOS

This commit is contained in:
Jarred Sumner
2022-01-04 04:00:06 -08:00
parent 61d6f8f18f
commit 623f77e097
2 changed files with 8 additions and 4 deletions

View File

@@ -84,3 +84,5 @@ pub const disable_compression_in_http_client = false;
// Time (mean ± σ): 306.7 ms ± 6.1 ms [User: 31.7 ms, System: 269.8 ms]
// Range (min … max): 299.5 ms … 318.8 ms 10 runs
pub const use_libgit2 = true;
pub const atomic_file_watcher = env.isLinux;

View File

@@ -532,10 +532,12 @@ pub fn NewWatcher(comptime ContextType: type) type {
comptime copy_file_path: bool,
) !void {
if (this.indexOf(hash)) |index| {
// On Linux, the file descriptor might be out of date.
if (fd > 0) {
var fds = this.watchlist.items(.fd);
fds[index] = fd;
if (comptime FeatureFlags.atomic_file_watcher) {
// On Linux, the file descriptor might be out of date.
if (fd > 0) {
var fds = this.watchlist.items(.fd);
fds[index] = fd;
}
}
return;
}