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
|
public sealed class AttributeKey<T> : AbstractConstant<AttributeKey<T>> |
|
{ |
|
public static readonly ConstantPool Pool = new AttributeConstantPool(); |
Unlike java, which does generic type erase;
AttributeKey<Class1>andAttributeKey<Class2>are 2 different types in dotnet, that mean they will use 2 separateAttributeConstantPool, and can both the sameId.That will make
DefaultAttributeMapinefficient(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 classstatic class AttributeKeyto hold all static methods and fields(or just fields for binary compatibility), and use the oldsealed class AttributeKey<T> : AbstractConstant<AttributeKey<T>>for the data class itself.***NOTE: *** It's always not safe for binary compatibility, sinceAttributeKey<T>.Poolis an public static field, and may be used by libs.Can be marked as Obsolete and set
AttributeKey<T>.Pool = AttributeKey.PoolDotNetty/src/DotNetty.Common/Utilities/AttributeKey.cs
Lines 15 to 17 in 72deeb9
DotNetty/src/DotNetty.Common/Utilities/DefaultAttributeMap.cs
Line 35 in 72deeb9