From: Carlos G. A. <car...@te...> - 2003-04-11 12:34:34
|
Mike Scott wrote: > Hi Carlos > > I see that the code has lots of field initialisers. This is not a good idea > as the initialisation IL is duplicated by the C# compiler for each > constructor, and prefixed in front of each constructors code. > > In other words, if you have 4 constructors, the output file will have the > same code to initialise the fields repeated 4 times. > > This is obviously wasteful and bloats code unnecessarily. It is recommended > to initialise your fields in your default constructor, then have all the > constructors call base(). Huummmm, i have no notice about this :), are you sure about it ( i have started to make the change in my local tree but i want to be sure about this before commit it, but in any case i think this can be good ) -- Best regards Carlos Guzmán Álvarez Vigo-Spain "No tengo dones especiales.Sólo soy apasionadamente curioso" Albert Einstein, científico. |
From: Mike S. <mi...@mi...> - 2003-04-11 13:58:15
|
Carlos Absolutely certain. Here's the IL for the second constructor of FbConnection. Note the initialisation of the fields before the code generated for the actual constructor source, which starts at offset 0054. Mike. .method public hidebysig specialname rtspecialname instance void .ctor(string cmdText, class FirebirdSql.Data.Firebird.FbConnection connection) cil managed { // Code size 99 (0x63) .maxstack 2 IL_0000: ldarg.0 IL_0001: newobj instance void FirebirdSql.Data.Firebird.FbParameterCollection::.ctor() IL_0006: stfld class FirebirdSql.Data.Firebird.FbParameterCollection FirebirdSql.Data.Firebird.FbCommand::parameters IL_000b: ldarg.0 IL_000c: ldc.i4.3 IL_000d: stfld valuetype [System.Data]System.Data.UpdateRowSource FirebirdSql.Data.Firebird.FbCommand::updatedRowSource IL_0012: ldarg.0 IL_0013: ldc.i4.0 IL_0014: stfld valuetype [System.Data]System.Data.CommandBehavior FirebirdSql.Data.Firebird.FbCommand::commandBehavior IL_0019: ldarg.0 IL_001a: ldc.i4.0 IL_001b: stfld bool FirebirdSql.Data.Firebird.FbCommand::disposed IL_0020: ldarg.0 IL_0021: ldc.i4.m1 IL_0022: stfld int32 FirebirdSql.Data.Firebird.FbCommand::actualCommand IL_0027: ldarg.0 IL_0028: ldc.i4.m1 IL_0029: stfld int32 FirebirdSql.Data.Firebird.FbCommand::recordsAffected IL_002e: ldarg.0 IL_002f: ldc.i4.0 IL_0030: stfld bool FirebirdSql.Data.Firebird.FbCommand::splitCommands IL_0035: ldarg.0 IL_0036: ldsfld string [mscorlib]System.String::Empty IL_003b: stfld string FirebirdSql.Data.Firebird.FbCommand::commandText IL_0040: ldarg.0 IL_0041: ldc.i4.1 IL_0042: stfld valuetype [System.Data]System.Data.CommandType FirebirdSql.Data.Firebird.FbCommand::commandType IL_0047: ldarg.0 IL_0048: ldc.i4.1 IL_0049: stfld bool FirebirdSql.Data.Firebird.FbCommand::designTimeVisible IL_004e: ldarg.0 IL_004f: call instance void [System]System.ComponentModel.Component::.ctor() IL_0054: ldarg.0 IL_0055: ldarg.1 IL_0056: call instance void FirebirdSql.Data.Firebird.FbCommand::set_CommandText(string) IL_005b: ldarg.0 IL_005c: ldarg.2 IL_005d: call instance void FirebirdSql.Data.Firebird.FbCommand::set_Connection(class FirebirdSql.Data.Firebird.FbConnection) IL_0062: ret } // end of method FbCommand::.ctor -----Original Message----- From: fir...@li... [mailto:fir...@li...]On Behalf Of Carlos Guzman Alvarez Sent: 11 April 2003 13:44 To: mi...@mi...; Firebird .Net Provider Subject: [Firebird-net-provider] Re: Initializing fields Mike Scott wrote: > Hi Carlos > > I see that the code has lots of field initialisers. This is not a good idea > as the initialisation IL is duplicated by the C# compiler for each > constructor, and prefixed in front of each constructors code. > > In other words, if you have 4 constructors, the output file will have the > same code to initialise the fields repeated 4 times. > > This is obviously wasteful and bloats code unnecessarily. It is recommended > to initialise your fields in your default constructor, then have all the > constructors call base(). Huummmm, i have no notice about this :), are you sure about it ( i have started to make the change in my local tree but i want to be sure about this before commit it, but in any case i think this can be good ) -- Best regards Carlos Guzmán Álvarez Vigo-Spain "No tengo dones especiales.Sólo soy apasionadamente curioso" Albert Einstein, científico. ------------------------------------------------------- This SF.net email is sponsored by: Etnus, makers of TotalView, The debugger for complex code. Debugging C/C++ programs can leave you feeling lost and disoriented. TotalView can help you find your way. Available on major UNIX and Linux platforms. Try it free. www.etnus.com _______________________________________________ Firebird-net-provider mailing list Fir...@li... https://lists.sourceforge.net/lists/listinfo/firebird-net-provider |
From: Carlos G. A. <car...@te...> - 2003-04-11 14:05:02
|
Helo: > Absolutely certain. Here's the IL for the second constructor of > FbConnection. Note the initialisation of the fields before the code > generated for the actual constructor source, which starts at offset 0054. Ok thanks very much, i'm going now to finish the cange and commit it to the CVS. -- Best regards Carlos Guzmán Álvarez Vigo-Spain "No tengo dones especiales.Sólo soy apasionadamente curioso" Albert Einstein, científico. |
From:
<car...@te...> - 2003-04-11 14:58:07
|
Hello: > Absolutely certain. Here's the IL for the second constructor of > FbConnection. Note the initialisation of the fields before the code > generated for the actual constructor source, which starts at offset 0054. I have added some changes for solve this to the CVS. -- Best regards Carlos Guzmán Álvarez Vigo-Spain |