IL Code for Freya.Demos.Complex.Equals

Back to source code.

.method public hidebysig virtual instance bool Equals(object Other) cil managed
{
    .entrypoint
    // Code Size: 63 byte(s)
    .maxstack 4
    .locals init (
           [0] Freya.Demos.Complex complex1)
    L_0000: ldarg.1 
    L_0001: brfalse.s L_003d
    L_0003: ldarg.1 
    L_0004: call instance [mscorlib]System.Type object::GetType()
    L_0009: ldtoken Freya.DataStructures.Complex
    L_000e: call [mscorlib]System.Type [mscorlib]System.Type::
                GetTypeFromHandle([mscorlib]System.RuntimeTypeHandle)
    L_0013: bne.un.s L_003d
    L_0015: ldarg.1 
    L_0016: unbox.any Freya.DataStructures.Complex
    L_001b: stloc.0 
    L_001c: ldarg.0 
    L_001d: ldfld float64 Freya.DataStructures.Complex::.Re
    L_0022: ldloca.s complex1
    L_0024: ldfld float64 Freya.DataStructures.Complex::.Re
    L_0029: bne.un.s L_003b
    L_002b: ldarg.0 
    L_002c: ldfld float64 Freya.DataStructures.Complex::.Im
    L_0031: ldloca.s complex1
    L_0033: ldfld float64 Freya.DataStructures.Complex::.Im
    L_0038: ceq 
    L_003a: ret 
    L_003b: ldc.i4.0 
    L_003c: ret 
    L_003d: ldc.i4.0 
    L_003e: ret 
}

IL Code before implementing some optimization techniques:

.method public hidebysig virtual instance bool Equals(object Other) cil managed
{
    .entrypoint
    // Code Size: 82 byte(s)
    .maxstack 4
    .locals init (
           [0] Freya.Demos.Complex complex1)
    L_0000: ldarg.1 
    L_0001: brfalse L_0050
    L_0006: ldarg.1 
    L_0007: call instance [mscorlib]System.Type object::GetType()
    L_000c: ldtoken Freya.DataStructures.Complex
    L_0011: call [mscorlib]System.Type [mscorlib]System.Type::
                GetTypeFromHandle([mscorlib]System.RuntimeTypeHandle)
    L_0016: ceq 
    L_0018: brfalse L_0050
    L_001d: ldarg.1 
    L_001e: unbox.any Freya.DataStructures.Complex
    L_0023: stloc.0 
    L_0024: ldarg.0 
    L_0025: ldfld float64 Freya.DataStructures.Complex::.Re
    L_002a: ldloca.s complex1
    L_002c: ldfld float64 Freya.DataStructures.Complex::.Re
    L_0031: ceq 
    L_0033: brfalse L_004e
    L_0038: ldarg.0 
    L_0039: ldfld float64 Freya.DataStructures.Complex::.Im
    L_003e: ldloca.s complex1
    L_0040: ldfld float64 Freya.DataStructures.Complex::.Im
    L_0045: ceq 
    L_0047: brfalse L_004e
    L_004c: ldc.i4.1 
    L_004d: ret 
    L_004e: ldc.i4.0 
    L_004f: ret 
    L_0050: ldc.i4.0 
    L_0051: ret 
}