Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2003-08

Patch win32: 'as' usage

5 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Mattias Gaertner
to Micha Nelissen: Attached patch greatly reduces the usage of the 'as' operator. Goal was to keep current…
Show quoted text 38 lines
Mattias Gaertner wrote: > On Sun, 31 Aug 2003 15:47:42 +0200 > Micha Nelissen 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. OK, I have made a new patch using assumption #1. Please apply it.

Done.

I haven't removed all 'as' usage: still half of them are there. It just seems very paranoid to use so much 'as'.

You should see the gtk lib code. ;)

Mattias

Reply by email

Micha Nelissen

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?
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.

HTH,

Micha.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: bin00064.bin
Type: application/octet-stream
Size: 3975 bytes
Desc: "as.patch.gz"
Url : http://localhost/pipermail/lazarus/attachments/20030831/f91cd73b/bin00064.bin

Reply by email

Micha Nelissen
to Micha Nelissen
Mattias Gaertner wrote 32 lines
On Sun, 31 Aug 2003 15:47:42 +0200 Micha Nelissen 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.

OK, I have made a new patch using assumption #1. Please apply it. I haven't removed all 'as' usage: still half of them are there. It just seems very paranoid to use so much 'as'.

Regards,

Micha.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: bin00065.bin
Type: application/octet-stream
Size: 5074 bytes
Desc: "as.patch.gz"
Url : http://localhost/pipermail/lazarus/attachments/20030831/0b433401/bin00065.bin

Reply by email

Mattias Gaertner
to Micha Nelissen: Attached patch greatly reduces the usage of the 'as' operator. Goal was to keep current…
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

Reply by email