TControl has the property Caption sefined as follows:
property Caption: TCaption read GetText write SetText stored
IsCaptionStored;
The procedure SetText is defined as follows:
procedure TControl.SetText(const Value: TCaption);
begin
if GetText <> Value then SetTextBuf(PChar(Value));
end;
So the Caption is only updated when it changes. Most component properties
will do this.
Stacey
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Sent: Monday, 17 April 2000 2:12 p.m.
> To: Multiple recipients of list delphi
> Subject: [DUG]: efficient code
>
>
>
> Just wondering, for a caption that doesn't change very oftern which in
> more efficient.
>
> StateLabel.caption := 'Running';
>
> OR
>
> IF StateLabel.Caption <> 'Running' then
> StateLabel.Caption := 'Running';
>
> This second makes larger code hence larger exe hence more
> overhead but the
> first updates the form which I am guessing would be slow. Does a label
> still get updated if the text is being assigned to it's current value?
>
> James
>
> --------------------------------------------------------------
> -------------
> New Zealand Delphi Users group - Delphi List -
> [EMAIL PROTECTED]
> Website: http://www.delphi.org.nz
>
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz