Actually, this is a misconception. The compiler cannot fold the code because Option.ItemIndex accesses a property, which translates to a method call, and therefore can have side-effects. (Yes folks, all property accesses are method calls, even if no accessor methods are defined and the property points directly at a variable.) So, if the optimiser were to fold the code, you would only get one method call instead of two! The only time when code is folder (and it is not even guaranteed), is when you directly access variables.
----- Original Message ----- From: "Rohit Gupta" <[EMAIL PROTECTED]> To: "Multiple recipients of list delphi" <[EMAIL PROTECTED]> Sent: Friday, October 31, 2003 12:07 PM Subject: Re: [DUG]: Just wondering... > First because the compiler should detect it and fodl the code. > > Second because it uses less cpu cycles. > > :-) > > I normally use a local variable to hold teh value with a name that > tells the world what it means. Or > > if Option.ItemIndex = 1 > then begin > end > else begin > end > > > > > Which of the following codeis the most efficient/fastest to execute? > > > > Label1.Enabled := Option.ItemIndex = 1; > > Label2.Enabled := Option.ItemIndex = 1; > > > > or > > > > Label1.Enabled := Option.ItemIndex = 1; > > Label2.Enabled := Label1.Enabled; > > > > Thanks, > > Ross Levis. > > > > > > > > Regards > > Rohit > > ====================================================================== > CFL - Computer Fanatics Ltd. 21 Barry's Point Road, AKL, New Zealand > PH (649) 489-2280 > FX (649) 489-2290 > email [EMAIL PROTECTED] or [EMAIL PROTECTED] > ====================================================================== > > > -------------------------------------------------------------------------- - > New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED] > Website: http://www.delphi.org.nz > To UnSub, send email to: [EMAIL PROTECTED] > with body of "unsubscribe delphi" > Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/ > --------------------------------------------------------------------------- New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED] Website: http://www.delphi.org.nz To UnSub, send email to: [EMAIL PROTECTED] with body of "unsubscribe delphi" Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/
