diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/FontCache/FontSourceCollection.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/FontCache/FontSourceCollection.cs index 65029d6eb83..42778aa0422 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/FontCache/FontSourceCollection.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/FontCache/FontSourceCollection.cs @@ -137,7 +137,7 @@ private void SetFontSources() { // fontPaths accumulates font file paths obtained from the registry and the file system // This collection is a set, i.e. only keys matter, not values. - Dictionary fontPaths = new Dictionary(512, StringComparer.OrdinalIgnoreCase); + HashSet fontPaths = new HashSet(512, StringComparer.OrdinalIgnoreCase); using (RegistryKey fontsKey = Registry.LocalMachine.OpenSubKey(InstalledWindowsFontsRegistryKey)) { @@ -154,16 +154,14 @@ private void SetFontSources() if (Path.GetFileName(fileName) == fileName) fileName = Path.Combine(Util.WindowsFontsLocalPath, fileName); - fontPaths[fileName] = null; + fontPaths.Add(fileName); } } } - foreach (string file in Directory.GetFiles(_uri.LocalPath)) - { - fontPaths[file] = null; - } - files = fontPaths.Keys; + fontPaths.UnionWith(Directory.EnumerateFiles(_uri.LocalPath)); + + files = fontPaths; } } else diff --git a/src/Microsoft.DotNet.Wpf/src/Shared/System/Windows/Markup/XmlCompatibilityReader.cs b/src/Microsoft.DotNet.Wpf/src/Shared/System/Windows/Markup/XmlCompatibilityReader.cs index 0c78c3a6a1b..147e2a12b38 100644 --- a/src/Microsoft.DotNet.Wpf/src/Shared/System/Windows/Markup/XmlCompatibilityReader.cs +++ b/src/Microsoft.DotNet.Wpf/src/Shared/System/Windows/Markup/XmlCompatibilityReader.cs @@ -1917,7 +1917,7 @@ class ProcessContentSet bool _all; string _namespaceName; XmlCompatibilityReader _reader; - Dictionary _names; + HashSet _names; public ProcessContentSet(string namespaceName, XmlCompatibilityReader reader) { @@ -1927,7 +1927,7 @@ public ProcessContentSet(string namespaceName, XmlCompatibilityReader reader) public bool ShouldProcessContent(string elementName) { - return _all || (_names != null && _names.ContainsKey(elementName)); + return _all || (_names != null && _names.Contains(elementName)); } public void Add(string elementName) @@ -1959,10 +1959,10 @@ public void Add(string elementName) { if (_names == null) { - _names = new Dictionary(); + _names = new HashSet(); } - _names[elementName] = null; // we don't care about value, just key + _names.Add(elementName); } } }