diff --git a/spine-csharp/src/Skin.cs b/spine-csharp/src/Skin.cs
index a0b997057..aed149be4 100644
--- a/spine-csharp/src/Skin.cs
+++ b/spine-csharp/src/Skin.cs
@@ -38,9 +38,10 @@ namespace Spine {
/// Stores attachments by slot index and attachment name.
public class Skin {
internal String name;
+ private Dictionary, Attachment> attachments =
+ new Dictionary, Attachment>(AttachmentComparer.Instance);
public String Name { get { return name; } }
- private Dictionary, Attachment> attachments = new Dictionary, Attachment>();
public Skin (String name) {
if (name == null) throw new ArgumentNullException("name cannot be null.");
@@ -86,5 +87,18 @@ namespace Spine {
}
}
}
+
+ // Avoids boxing in the dictionary.
+ private class AttachmentComparer : IEqualityComparer> {
+ internal static readonly AttachmentComparer Instance = new AttachmentComparer();
+
+ bool IEqualityComparer>.Equals (KeyValuePair o1, KeyValuePair o2) {
+ return o1.Key == o2.Key && o1.Value == o2.Value;
+ }
+
+ int IEqualityComparer>.GetHashCode (KeyValuePair o) {
+ return o.Key;
+ }
+ }
}
}