Re: Jumps through a program

From: Jeffrey Baker (x1x1_at_tmove.com)
Date: 11/19/03


Date: Wed, 19 Nov 2003 16:40:25 GMT


"Thomas Matthews" <Thomas_MatthewsHatesSpam@sbcglobal.net> wrote in message
news:hDMub.31148$_n7.3883@newssvr31.news.prodigy.com...
> Jeffrey Baker wrote:
>
> > Technically, which is more efficient, to jump to the 100th function of
one
> > class or to jump to the 100th class? Class would be through inheritance
as
> > an object. Is there a comment on embeded objects to this subject too?
> >
> > Regards,
> > Jeffrey Baker
>
> If a class has 100 methods (member functions), executing any one of them
> is of order O(1) (unless they are virtual). The compiler will know the
> location of the function and supply code to call the function. Check
> your assembly code.
>
> If you have 100 individual classes then use a method from one of the
> classes (i.e. class_99.method()) this would be of order O(1). Again,
> the compiler will know the location of the function and insert the
> appropriate calling code.
>
> Some concepts that may add another layer of indirection:
> 1. inheritance
> 2. virtual methods
> 3. pointers to methods or functions.
>
> Inheritance may add another layer of indirection if the compiler
> must supply run-time code to find the function. Otherwise, the
> function is at a known location and the order is O(1).
>
> Virtual methods require some kind of run-time evaluation to
> find the correct method to execute. Some compilers speed up
> the process by using a table, although that isn't required.
>
> Pointers to methods or functions require that the compiler
> issue code to dereference the pointer before executing
> the function. This is a minimum of 1 level of indirection.
>
> I don't understand what your definition of "embeded objects"[sic]
> is. I work on embedded systems and my understanding may be
> different than yours. Please clarify.
Actually I don't know what I meant. I think I was thinking in terms of
another language in terms of basic way back when. I actually answered my
question after my sent post. Been away from C++ for a while. Thanks for
waking me up.

-- 
It is better to post code then to never tried.
Jeffrey Baker
>
> -- 
> Thomas Matthews
>
> C++ newsgroup welcome message:
>           http://www.slack.net/~shiva/welcome.txt
> C++ Faq: http://www.parashift.com/c++-faq-lite
> C Faq:   http://www.eskimo.com/~scs/c-faq/top.html
> alt.comp.lang.learn.c-c++ faq:
>           http://www.raos.demon.uk/acllc-c++/faq.html
> Other sites:
>      http://www.josuttis.com  -- C++ STL Library book
>


Relevant Pages

  • Re: Jumps through a program
    ... Jeffrey Baker wrote: ... Class would be through inheritance as ... the compiler will know the location of the function and insert the ... C++ Faq: http://www.parashift.com/c++-faq-lite ...
    (comp.lang.cpp)
  • Re: C Overflow and MSVC++
    ... Jeff Schwab wrote: ... >> is using that compiler. ... > don't believe MS's documentation guarantees this behavior). ... a.c.l.l.c-c++ FAQ mirror: http://nullptr.merseine.nu:8080/acllcc++.html ...
    (alt.comp.lang.learn.c-cpp)
  • Re: Help with voids
    ... I don't like the explaination in the FAQ though. ... would correctly assign 10 to intv on this machine (since the character ... In any event, since we lied to the compiler here, the compiler sees ...
    (comp.lang.c)
  • Re: Member template instantiation confusion
    ... Rick Armstrong wrote: ... > ...so I'd say that the compiler should instantiate ... Except that the compiler is not alowed to do any conversions on the ... a.c.l.l.c-c++ FAQ mirror: http://nullptr.merseine.nu:8080/acllcc++.html ...
    (alt.comp.lang.learn.c-cpp)
  • Re: accessor member functions and const
    ... > I read would be to declare the copy assignment operator (and copy ... the warning level of your compiler as high as it will go. ... Another option is to use a lint tool, like PCLint, FlexeLint or splint ... a.c.l.l.c-c++ FAQ: http://www.comeaucomputing.com/learn/faq ...
    (alt.comp.lang.learn.c-cpp)