-
Notifications
You must be signed in to change notification settings - Fork 1k
Description
Unlike java, which does generic type erase; AttributeKey<Class1> and AttributeKey<Class2> are 2 different types in dotnet, that mean they will use 2 separate AttributeConstantPool, and can both the same Id.
That will make DefaultAttributeMap inefficient(still work, just inefficient)
, because it always use bucket-1, and never use 0,2,3 when you use more than 1 AttributeKey<T> and always with different types.
Maybe AttributeKey<T> needed to be separated to 2 types(like System.Tuple and System.Tuple<T1,...>), use an new utils class static class AttributeKey to hold all static methods and fields(or just fields for binary compatibility), and use the old sealed class AttributeKey<T> : AbstractConstant<AttributeKey<T>> for the data class itself.
***NOTE: *** It's always not safe for binary compatibility, since AttributeKey<T>.Pool is an public static field, and may be used by libs.
Can be marked as Obsolete and set AttributeKey<T>.Pool = AttributeKey.Pool
DotNetty/src/DotNetty.Common/Utilities/AttributeKey.cs
Lines 15 to 17 in 72deeb9
| public sealed class AttributeKey<T> : AbstractConstant<AttributeKey<T>> | |
| { | |
| public static readonly ConstantPool Pool = new AttributeConstantPool(); |
| int i = Index(key); |