By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,750 Members | 1,187 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,750 IT Pros & Developers. It's quick & easy.

get() function vs public member

P: n/a
Hello
I profiled my program and got as result that two functions taking each
10% of the calculation time are simple get() for a member of a class
(returning a pointer).

Do you think that generally accessing this member directly (making it
public) would speed up things vs using the get function as an interface?

(if you thinks this might be compiler related, I'm using the following
gcc 3.3.1 (used for profiling with gprof on win2k)
icc 7.1 (for production, on linux)
Metrowerks Code Warrior C++ compiler 3.0.3 (for developping on win2k)

Thanks for your answers
Philipp
Jul 22 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
> Hello
I profiled my program and got as result that two functions taking each
10% of the calculation time are simple get() for a member of a class
(returning a pointer).

Do you think that generally accessing this member directly (making it
public) would speed up things vs using the get function as an interface?


At least on MSVC 7.0 or newer, with properly configured optimization there
should be completely no performance hit, even in the get() functions are
defined in different module than they are used from.

Marcin
Jul 22 '05 #2

P: n/a
Philipp wrote:

Hello
I profiled my program and got as result that two functions taking each
10% of the calculation time are simple get() for a member of a class
(returning a pointer).

Do you think that generally accessing this member directly (making it
public) would speed up things vs using the get function as an interface?
Did you make the getter an inline function?
If so and the compiler inlined that function (very likely), there
should be absolutely no performance difference.

(if you thinks this might be compiler related, I'm using the following
gcc 3.3.1 (used for profiling with gprof on win2k)
icc 7.1 (for production, on linux)
Metrowerks Code Warrior C++ compiler 3.0.3 (for developping on win2k)

Thanks for your answers
Philipp

--
Karl Heinz Buchegger
kb******@gascad.at
Jul 22 '05 #3

P: n/a
Karl Heinz Buchegger wrote:
Did you make the getter an inline function?


No, I will try this.

Phil
Jul 22 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.