On 22 Jul 2010, at 23:10, Luiz Americo Pereira Camara wrote:

In Lazarus i just committed the following code:

  if Alignment <> FDataLink.Field.Alignment then
    Alignment := FDataLink.Field.Alignment;

but i could do also:

 Alignment := FDataLink.Field.Alignment;

The setter property of Alignment already checks if the passed value is equal:
[snip]
Is worth removing the check?

Yes.

The cost of not doing the call compensates the extra code added by the check?

In general, it's best to keep any code that is not speed critical as small as possible. The reason is that it will then displace less other code from the instruction cache, and removing less code from the instruction cache will almost always result in faster programs than some micro-optimization here or there.


Jonas
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to