diff options
author | Vsevolod Kukol <sevoku@microsoft.com> | 2020-01-14 11:48:24 +0300 |
---|---|---|
committer | Vsevolod Kukol <sevoku@microsoft.com> | 2020-01-14 16:16:32 +0300 |
commit | 627c056def02c66607ec00ee116d4e8ce71d558f (patch) | |
tree | bdb2eee2c716d9cfbb56271096e4830e7519232a | |
parent | aa30f974df43ea1d194e475bef006b27d9c16718 (diff) |
[Ide] Improve ImageService.CustomImageLoader
* sort resources by name, to ensure same sequence for all icons
* use a global static dictionary for loaded resources
* filter by requested name to avoid Xwt.Image parser scanning all resources over and over again
-rw-r--r-- | main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/ImageService.cs | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/ImageService.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/ImageService.cs index b1dc79a125..cd1b75f497 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/ImageService.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/ImageService.cs @@ -913,7 +913,7 @@ namespace MonoDevelop.Ide class CustomImageLoader : Xwt.Drawing.IImageLoader { RuntimeAddin addin; - Dictionary<System.Reflection.Assembly, string []> resources = new Dictionary<System.Reflection.Assembly, string[]> (); + static Dictionary<System.Reflection.Assembly, List<string>> resources = new Dictionary<System.Reflection.Assembly, List<string>> (); public CustomImageLoader (RuntimeAddin addin) { @@ -924,11 +924,12 @@ namespace MonoDevelop.Ide { var r = addin.GetResourceInfo (fileName); - string [] resourceList; - if (!resources.TryGetValue (r.ReferencedAssembly, out resourceList)) - resourceList = resources [r.ReferencedAssembly] = r.ReferencedAssembly.GetManifestResourceNames (); + if (!resources.TryGetValue (r.ReferencedAssembly, out var resourceList)) { + resourceList = resources [r.ReferencedAssembly] = r.ReferencedAssembly.GetManifestResourceNames ().ToList (); + resourceList.Sort (); // sort resources by name + } - return resourceList; + return resourceList.Where (r => r.StartsWith (baseName) && r.EndsWith (ext)); } public Stream LoadImage (string fileName) |