Show quoted text 11 lines
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