Complete.Org: Mailing Lists: Archives: freeciv-dev: January 2004:
[Freeciv-Dev] Re: (PR#7195) inlining map_pos_to_index
Home

[Freeciv-Dev] Re: (PR#7195) inlining map_pos_to_index

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: jshort@xxxxxxxxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#7195) inlining map_pos_to_index
From: "Brandon J. Van Every" <vanevery@xxxxxxxxxxxxxxxxxxx>
Date: Mon, 5 Jan 2004 13:50:57 -0800
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=7195 >

Marek wrote:
> RossW wrote:
>  
> > The key elements are:
> > 1)  inline functions are merely a *hint* to the compiler 
> >      with no hard requirement to actually inline the code.
> 
> But a darn strong one. In gcc, defining a function as extern inline
> makes the compiler to not emit the body of the function (ie. doing
> &inlined_function would result in link error.)

Ok, I've been trying really hard to shut up, and succeeding.  But I'm now going 
to obnoxiously interject in an increasingly obnoxious discussion.  Having spent 
my entire career on low-level ASM optimization bullshit, and having seen 
*plenty* of inline compilers, I'm inclined to weigh in on this language 
religious wars gobbledygook nonsense.

There are 2 issues:
1) *WHY* are you trying to optimize?  Really, what's in it for you?
2) If you are trying to optimize, *WHAT COMPILER* are you using?

(1) is the bit that's ticking me off.  Here you are, yadda yadding about C 
style this or that.  It's micromanagerial, and misses the forest for the sake 
of the trees.  Strategically you should *either* be doing something OO in a 
higher level language, 'cuz optimization usually doesn't impact the bottom line 
and your programmer time is better spent, *or* implement a very obvious / 
needed performance improvement.  And it seems like the case under current 
discussion is the latter, so what's all the pissing and moaning about macros 
vs. inlines about?  IF IT WORKS, USE IT.

(2) adds insult to injury.  GCC might be *wonderful* at inlining.  I'm using 
Visual Studio .NET 2003, and I can assure you its inlining is bollocks.  People 
tell me the Intel compiler ain't so hot either.  The DEC Alpha NT compiler was 
an absolute jewel of technology and I only had to write ASM code for very 
specific classes of problems.

Ergo, in cross-platform development, you cannot make assumptions about what 
will or won't be inlined.  Maybe it works *great*.  Maybe it works *terrible*.  
There's no a priori reason to decide one way or the other.  The worthwhile 
general recommendations are:

1) feel free to #ifdef based on target compiler
2) don't assume lotsa inlines will play well with each other
3) don't assume long inlines will get inlined

If you Keep it Simple Stupid, inlines often work fine.  If they don't, use the 
damn macro.  AND QUIT ARGUING ABOUT THE "RIGHT" WAY, ***PLEASE*** !!!!


Cheers,                         www.indiegamedesign.com
Brandon Van Every               Seattle, WA

"We live in a world of very bright people building
crappy software with total shit for tools and process."
                                - Ed Mckenzie





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