[Lazarus] property setter
ip at kmiac.ru
Thu Jan 24 03:18:15 CET 2013
24.01.2013 10:08, xrfang пишет:
> procedure TPainter.SetFont(AValue: TFont);
> if FFont=AValue then Exit;
> My question is, why the "if" clause needed? Is there any performance
Usually setters have more complex code than just FFont:=AValue;
In this case If block protects both code performance and code logic.
Setters usually should not perform any actions if they are called with
the same value as property have.
If setter only assigns a value to a field then probably it can be
replaced with the field in the property declaration.
More information about the Lazarus