I've made some small examples in VB and C# thay were doing this:
private void Form1_Load(object sender, System.EventArgs e){
int b = 9966;
Doh (b); }
and that
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim b As Int32 = 9966
Doh(b)
End Sub
Public Sub Doh(ByRef a As Integer)
End Sub
i've compiled tham and decompiled using Salamander
(http://www.remotesoft.com/salamander/index.html)
My intention was to see how do pointer work in C# with regards to VB.net
byref.
What i've seen was a big difference that may cause big speed decrease in vb.
I just don't know why because reference are in practice safe way of
transfering variables' addresses.
look
.maxstack 2 //same
.locals (int32) //same
IL_0000: ldc.i4 9966 //same
IL_0005: stloc.0 //same
IL_0006: ldarg.0 //same
IL_0007: ldloca.s 0 //same
IL_0009: call instance void
WindowsApplication5.Form1::Doh(int32*)
IL_000e: ret
vs. (VB)
.maxstack 2 //same
.locals (int32) //same
IL_0000: nop //WHAT FOR!
IL_0001: ldc.i4 9966
IL_0006: stloc.0 //same
IL_0007: ldarg.0 //same
IL_0008: ldloca.s 0 //same
IL_000a: callvirt instance void
WindowsApplication4.Form1::Doh(int32&) // differs with virt and "&"
IL_000f: nop //WHAT FOR!
IL_0010: nop //WHAT FOR!
IL_0011: ret //same
So:
Is callvirt faster than call ?
why can't ref int be called using using call and int32* ? Whas it to
difficult, or is it faster?
What the hell are those NOOPS for? To make VB slower?
I'm shocked!
Can you explain it in any way?