From 127b538298af30c83acd078b8347a06fa9857780 Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Wed, 25 Aug 2021 11:16:18 -0700 Subject: [PATCH] Use bulk unsubscribe operations in FileChangeWatcher --- .../ProjectSystem/FileChangeWatcher.cs | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/FileChangeWatcher.cs b/src/VisualStudio/Core/Def/Implementation/ProjectSystem/FileChangeWatcher.cs index 3736da29b792d..7d8f50074dea3 100644 --- a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/FileChangeWatcher.cs +++ b/src/VisualStudio/Core/Def/Implementation/ProjectSystem/FileChangeWatcher.cs @@ -417,20 +417,12 @@ public async ValueTask ApplyAsync(IVsAsyncFileChangeEx service, CancellationToke case Kind.UnwatchDirectories: Contract.ThrowIfFalse(_cookies is not null); - foreach (var unwatchCookie in _cookies) - { - await service.UnadviseDirChangeAsync(unwatchCookie, cancellationToken).ConfigureAwait(false); - } - + await service.UnadviseDirChangesAsync(_cookies, cancellationToken).ConfigureAwait(false); return; case Kind.UnwatchFiles: Contract.ThrowIfFalse(_tokens is not null); - foreach (var token in _tokens) - { - await service.UnadviseFileChangeAsync(token.Cookie!.Value, cancellationToken).ConfigureAwait(false); - } - + await service.UnadviseFileChangesAsync(_tokens.Select(token => token.Cookie!.Value).ToArray(), cancellationToken).ConfigureAwait(false); return; default: