15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


OnUpdate...

Colin Angus Mackay -- colin.angus.mackay@dial.pipex.com
Friday, January 31, 1997

Environment: VC++ 4.1; Win 95; Win NT 3.51, 4.0

Hi,

In my application I have many menu items and toolbar items that can be =
disabled because of some condition that I have code like the following =
all over my application:

void CMyView::OnUpdateSomething(CCmdUI* pCmdUI)=20
{
	pCmdUI->Enable(m_bSomeCondition);
}

Given that most of these OnUpdate... functions are mearly a line or two =
of code, what would the effect of making them inline be. Is there any =
benefit from this? or are these functions called so often from the =
framework it would mearly bloat the resulting EXE file?

Colin Angus Mackay.




Brad Wilson/Crucial Software -- crucial@pobox.com
Saturday, February 01, 1997

[Mini-digest: 2 responses]

>>> Given that most of these OnUpdate... functions are mearly a line or two
of code, what would the effect of making them inline be.

You can't make them inline.

The message dispatch keeps pointers to functions.  You can't keep a pointer
to an inline function, since it has no body.  If you add the inline keyword
to this function, one of two things may happen (not sure which):  (a)
compile/link error; (b) compiler will ignore you.

More than likely (b).  The inline keyword is a suggestion to the compiler,
not a mandate.

--
Brad Wilson, Objectivist   crucial@pobox.com   http://www.thebrads.com/

"No, his mind is not for rent . To any god or government
 Always hopeful, but discontent . He knows changes aren't permanent
 But change is..."    - Tom Sawyer (from the Rush CD "Moving Pictures")

-----From: Mike Blaszczak 

At 11:37 1/31/97 -0000, Colin Angus Mackay wrote:
>Environment: VC++ 4.1; Win 95; Win NT 3.51, 4.0

>In my application I have many menu items and toolbar items
>that can be disabled because of some condition that I have
>code like the following all over my application:

>void CMyView::OnUpdateSomething(CCmdUI* pCmdUI) 
>{
>	pCmdUI->Enable(m_bSomeCondition);
>}

>Given that most of these OnUpdate... functions are mearly a
>line or two of code, what would the effect of making them
>inline be.

Nothing.  The compiler can't inline them, and will ignore you
when you use the "inline" keyword.  The functions are
implementations of virtual functions, so they can't be inlined.

You might want to try using ON_UPDATE_COMMAND_UI_RANGE() to
coalesce similar functions.  You'll need to make the related
items have numerically adjacent ID's, though.

>Is there any benefit from this? or are these functions called
>so often from the framework it would mearly bloat the resulting EXE file?

No.  Inlining only happens within the same compilation unit, not
across compilation units.  It's impossible for you to bloat MFC;
it's only possible for me and my colleagues to do it.

.B ekiM

.B ekiM
http://www.nwlink.com/~mikeblas/
These words are my own. I do not speak on behalf of Microsoft.
           This performance was not lip-synched.




Yoong Hor Meng -- eng30391@leonis.nus.sg
Monday, February 03, 1997

[Mini-digest: 4 responses]


->In my application I have many menu items and toolbar items that can be disabled because of some condition that I have code like the following all over my application:
->
->void CMyView::OnUpdateSomething(CCmdUI* pCmdUI) 
->{
->	pCmdUI->Enable(m_bSomeCondition);
->}
->functions are mearly a line or two of code, what would the effect of making them inline be.

	Inline function will be stored together with class member
data for fast accessing them, ie stored inside data segment (This is for
16-bits architecture, I am not sure for 32 bits one). If you have several
intance of the same class, the inline code will be dupliated several
times.  If you put the code in the normal way ("outline" I supposed), the
code will one make once, ie in the data segment.

-----From: =?iso-8859-1?Q?Klaus_G=FCtter?= 

Colin,

these OnUpdate... functions are called via a message map. Remember that
a message map is basically an array of (ID, function pointer) pairs. A
function called via a function pointer cannot be inlined by the compiler
because the pointer will have to point to a real function's code. So the
best you may expect from declaring OnUpdate... inline is that the
compiler will ignore it.

- Klaus

>----------
>Von: 	Colin Angus Mackay[SMTP:colin.angus.mackay@dial.pipex.com]
>Gesendet: 	Freitag, 31. Januar 1997 12:37
>An: 	'~MFC Mailing List'
>Betreff: 	OnUpdate...
>
>Environment: VC++ 4.1; Win 95; Win NT 3.51, 4.0
>
>Hi,
>
>In my application I have many menu items and toolbar items that can be
>disabled because of some condition that I have code like the following all
>over my application:
>
>void CMyView::OnUpdateSomething(CCmdUI* pCmdUI) 
>{
>	pCmdUI->Enable(m_bSomeCondition);
>}
>
>Given that most of these OnUpdate... functions are mearly a line or two of
>code, what would the effect of making them inline be. Is there any benefit
>from this? or are these functions called so often from the framework it would
>mearly bloat the resulting EXE file?
>
>Colin Angus Mackay.
>
-----From: Doncho Angelov 

Hi Colin !

I'm afraid that these functions cannot be implemented as inline. Being =
inline for a function is just a simple instruction to the compiler when =
it includes .h file to make instead of calling the function x() (which =
is inline) to put it's code in your code, where you call the function. =
Having in mind that you compile only your code and the OnUpdate... =
functions are called from the framework, I think that the inline =
specifier will not work (if it doesn't issue an error message, I'm not =
sure).

--- This is to all the members of MFC-L group ---
I've shared my thoughts with Colin about the subject he asked for. =
However, I'm not too much experienced in MFC like some of the 'brights' =
I see here. If I'm mistaked for something, please let me know
Thank you in advance !
---

Doncho

----------
From: 	Colin Angus Mackay[SMTP:colin.angus.mackay@dial.pipex.com]
Sent: 	Friday, January 31, 1997 1:37 PM
To: 	'~MFC Mailing List'
Subject: 	OnUpdate...

Environment: VC++ 4.1; Win 95; Win NT 3.51, 4.0

Hi,

In my application I have many menu items and toolbar items that can be =
disabled because of some condition that I have code like the following =
all over my application:

void CMyView::OnUpdateSomething(CCmdUI* pCmdUI)=20
{
	pCmdUI->Enable(m_bSomeCondition);
}

Given that most of these OnUpdate... functions are mearly a line or two =
of code, what would the effect of making them inline be. Is there any =
benefit from this? or are these functions called so often from the =
framework it would mearly bloat the resulting EXE file?

Colin Angus Mackay.


-----From: Roma 

Colin Angus Mackay wrote:
> 
> Environment: VC++ 4.1; Win 95; Win NT 3.51, 4.0
> 
> Hi,
> 
> In my application I have many menu items and toolbar items that can be disabled because of some condition that I have code like the following all over my application:
> 
> void CMyView::OnUpdateSomething(CCmdUI* pCmdUI)
> {
>         pCmdUI->Enable(m_bSomeCondition);
> }
> 
> Given that most of these OnUpdate... functions are mearly a line or two 
>of code, what would the effect of making them inline be. Is there any 
>benefit from this? or are these functions called so often from the 
>framework it would mearly bloat the resulting EXE file?
 Hello, Colin.

 Message maps is basically arrays which contains message IDs and
associated
 function *addresses*. Inline function can't have an address, that's why
you
 can't declare message hadler as inline function, or even if you can
make such 
 declaration, compiler will definetly ignore it.
-Roma



> 
> Colin Angus Mackay.




| Вернуться в корень Архива |