octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: symtab.h: why so many function bodies


From: Olaf Till
Subject: Re: symtab.h: why so many function bodies
Date: Wed, 24 Feb 2016 09:52:13 +0100
User-agent: Mutt/1.5.23 (2014-03-12)

On Tue, Feb 23, 2016 at 08:23:05PM -0800, LachlanA wrote:
> Why are so many of the functions in   class symbol_table   defined in
> symtab.h instead of symtab.cc?   Since many files include symtab.h, there
> seems to be an unnecessary amount of recompiling when debugging those
> functions.
> 
> If it is to make the code inline, wouldn't declaring it as inline would be
> just as effective?

No, code can't be made inline outside the object in which it is
compiled, can it? You have to compile the code in each object in which
you want to have it inline ...

But your point may be valid nevertheless, the question is whether such
larger functions benefit sufficiently from being inlined to effort
compiling them again.

> I can understand all of the tiny functions that simply call
> rep->same_function(), but substantial functions like
> 
>      void clear (scope_id s)
>       {
>         if (! (is_hidden () || is_inherited ())
>             && s == scope ())
>           {
>             if (is_global ())
>               unmark_global ();
> 
>             if (is_persistent ())
>               {
>                 symbol_table::persistent_assign (name, varval ());
> 
>                 unmark_persistent ();
>               }
> 
>             assign (octave_value ());
>           }
>       }
> 
> seem to belong in symtab.cc.

This example has some conditional branching, one integer(?)
assignment, and calls of other functions. Probably not much machine
code, depending on whether the other functions called are also inlined
or not, and how large they are. So it could be worth inlining 'void
clear (scope_id)' ...

Olaf

-- 
public key id EAFE0591, e.g. on x-hkp://pool.sks-keyservers.net

Attachment: signature.asc
Description: Digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]