■30609 / ) |
Re[3]: 参照型の等値演算子でboxingを回避したい |
□投稿者/ ほにゃ (3回)-(2008/12/27(Sat) 22:40:18)
|
ildasm.exeだとこんな感じです。
.method public hidebysig static bool Test3<(BoxingTest.HogeClass) T>(!!T x,
!!T y) cil managed
{
// コード サイズ 20 (0x14)
.maxstack 2
.locals init ([0] bool CS$1$0000)
//000021: public static bool Test3<T>(T x, T y) where T : HogeClass { return x == y; }
IL_0000: nop
IL_0001: ldarg.0
IL_0002: box !!T
IL_0007: ldarg.1
IL_0008: box !!T
IL_000d: ceq
IL_000f: stloc.0
IL_0010: br.s IL_0012
IL_0012: ldloc.0
IL_0013: ret
} // end of method Test::Test3
.method public hidebysig static bool Test4<class (BoxingTest.IHoge) T>(!!T x,
!!T y) cil managed
{
// コード サイズ 20 (0x14)
.maxstack 2
.locals init ([0] bool CS$1$0000)
//000022: public static bool Test4<T>(T x, T y) where T : class, IHoge { return x == y; }
IL_0000: nop
IL_0001: ldarg.0
IL_0002: box !!T
IL_0007: ldarg.1
IL_0008: box !!T
IL_000d: ceq
IL_000f: stloc.0
IL_0010: br.s IL_0012
IL_0012: ldloc.0
IL_0013: ret
} // end of method Test::Test4
IL_0002: box !!T ← x
IL_0008: box !!T ← y
ではないかと、想像してるのですが。
|
|