From b1dd7b418136c791e0331ec7711421f285a2a54c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=98=E9=9F=AC=20=E5=BC=A0?= Date: Sun, 15 Nov 2020 21:03:39 +0800 Subject: [PATCH] Move Image Cache filtering earlier --- Flow.Launcher.Infrastructure/Image/ImageCache.cs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/Flow.Launcher.Infrastructure/Image/ImageCache.cs b/Flow.Launcher.Infrastructure/Image/ImageCache.cs index 7482ac1cf..cce0aaace 100644 --- a/Flow.Launcher.Infrastructure/Image/ImageCache.cs +++ b/Flow.Launcher.Infrastructure/Image/ImageCache.cs @@ -26,7 +26,7 @@ namespace Flow.Launcher.Infrastructure.Image private const int MaxCached = 50; public ConcurrentDictionary Data { get; private set; } = new ConcurrentDictionary(); private const int permissibleFactor = 2; - + public void Initialization(Dictionary usage) { foreach (var key in usage.Keys) @@ -65,15 +65,13 @@ namespace Flow.Launcher.Infrastructure.Image if (Data.Count > permissibleFactor * MaxCached) { // To delete the images from the data dictionary based on the resizing of the Usage Dictionary. - - - foreach (var key in Data.Where(x => x.Key != Constant.MissingImgIcon) + foreach (var key in Data + .Where(x => x.Key != Constant.MissingImgIcon + && x.Key != Constant.ErrorIcon + && x.Key != Constant.DefaultIcon) .OrderBy(x => x.Value.usage).Take(Data.Count - MaxCached).Select(x => x.Key)) { - if (!(key.Equals(Constant.ErrorIcon) || key.Equals(Constant.DefaultIcon))) - { - Data.TryRemove(key, out _); - } + Data.TryRemove(key, out _); } } }