Use dictionary to track PackageRelationships instead of searching a list (#35978)
authorTaylor Southwick <tasou@microsoft.com>
Thu, 28 May 2020 18:48:08 +0000 (11:48 -0700)
committerGitHub <noreply@github.com>
Thu, 28 May 2020 18:48:08 +0000 (11:48 -0700)
commit0249b0f7f4caee76c1687109de2600af7301d62b
tree6812d60506085b7870529c75292faa13ab73c926
parent5f9119ed1f59a072ce6ab52e43479279d83c274a
Use dictionary to track PackageRelationships instead of searching a list (#35978)

This change adds an OrderedDictionary<TKey,TValue> type to System.IO.Packaging to keep a list of relationships that have been added, while ensuring that the ids are unique with decent performance characteristics. The current implementation searches a list which gets really slow with large numbers of relationships. A Dictionary by itself does not work for this as the order of addition is important. Thus, this combines a LinkedList to track the order, while a Dictionary is used to for quick look up of existing items.
src/libraries/System.IO.Packaging/src/System.IO.Packaging.csproj
src/libraries/System.IO.Packaging/src/System/IO/Packaging/InternalRelationshipCollection.cs
src/libraries/System.IO.Packaging/src/System/IO/Packaging/OrderedDictionary.cs [new file with mode: 0644]
src/libraries/System.IO.Packaging/src/System/IO/Packaging/PackageRelationshipCollection.cs