Yeah, I'd have to wonder why you're too worried about it too...
 
I'm assuming that OptionIndex is a combobox/listbox or similar?
 
If so, a quick look at the source would suggest that using the ItemIndex property could be slower since it fires a Windows Message off within its implementation, whereas the Enabled property is simply reading the value of an internal field.  Hence, I'd suggest minimising the number of times you use the ItemIndex property.
 
Use the source, Luke... ;-)
 
HTH,
 
Conor
-----Original Message-----
From: Leigh Wanstead [mailto:[EMAIL PROTECTED]
 
Hi Ross,
 
You need to time it.
 
I don't know how you implement Option.ItemIndex.
 
If you think both are slow, you may introduce a temp i.e.
 
bEnabled := Option.ItemIndex = 1;
Label1.Enabled := bEnabled;
Label2.Enabled := bEnabled;
 
By the way, I don't think this speed improvement should attract your attention.
 
Regards
Leigh
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]On Behalf Of Ross Levis
Sent: Thursday, October 30, 2003 9:24 PM
To: Multiple recipients of list delphi
Subject: [DUG]: Just wondering...

Which of the following code is 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.

Reply via email to