Ross, if you take a look at the code that gets executed when you enable the
button:
procedure TControl.SetEnabled(Value: Boolean);
begin
if FEnabled <> Value then
begin
FEnabled := Value;
Perform(CM_ENABLEDCHANGED, 0, 0);
end;
end;
you see that it only changes the Enabled property value if it has to.
So I would go for option 1 - mainly in the interest of keeping the code
clear. I haven't tested it, but I think the speed difference would be
negligible.
John
-----Original Message-----
From: Ross Levis [mailto:[EMAIL PROTECTED]]
Sent: Friday, 27 July 2001 2:55 pm
To: Multiple recipients of list delphi
Subject: [DUG]: Speed question
Which of the following statements execuates faster if the button is
already enabled?
1. OKButton.Enabled := True;
2. if OKButton.Enabled = False then OKButton.Enabled := True;
If the answer is 2, does anyone bother doing it that way?
Also, if I'm enabling the button in numerous procedures, is it
better/faster to execute a procedure with just the one line in it?
Cheers,
Ross.
---------------------------------------------------------------------------
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/