[lazarus] Patch win32: 'as' usage

Mattias Gaertner nc-gaertnma at netcologne.de
Sun Aug 31 10:05:43 EDT 2003


On Sun, 31 Aug 2003 15:47:42 +0200
Micha Nelissen <M.Nelissen at student.tue.nl> wrote:

> Hi,
> 
> Attached patch greatly reduces the usage of the 'as' operator. Goal was 
> to keep current functionality: only changes are made to those statements 
> where the type was already verified before, either by 'is' or another
> 'as'.
> 
> Question: what assumptions can we make about function entry? Then we can 
> further reduce usage of as.
> 1) Can we assume Sender parameter is of type as FCompStyle indicates? 
> Ie. csButton is a TButton?

Yes.


> 2) Can we assume basic class like TWinControl? Some function seem to 
> assume it by starting with an 'as' right at the beginning of the 
> function. It may be an idea to change 'Sender: TObject' to 'Sender: 
> TWinControl' if this is the case.

Yes, for most functions. There are some exceptions: dialog's and menu's base
class is only TComponent.
Also consider that replacing an 'as' operator, that is not in a loop, will
not get any measurable acceleration and you will loose an extra consistency
check. 


Mattias






More information about the Lazarus mailing list