www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - inlining

reply spir <denis.spir gmail.com> writes:
Hello,

Does dmd inline when appropriate (eg single-line func)? or is there a hint =
keyword? or what else?
Eg how to have this inlined:

private bool isPrecomposedHangulSylable (Code code) {
    /** whether code is a precomposed Hangul syllable ;-) */
    return (code >=3D FIRST_HANGUL_SYLLABLE) && (code <=3D LAST_HANGUL_SYLL=
ABLE);
}

Thank you,
Denis
-- -- -- -- -- -- --
vit esse estrany =E2=98=A3

spir.wikidot.com
Dec 07 2010
parent Christopher Nicholson-Sauls <ibisbasenji gmail.com> writes:
On 12/07/10 05:05, spir wrote:
 Hello,
 
 Does dmd inline when appropriate (eg single-line func)? or is there a hint
keyword? or what else?
 Eg how to have this inlined:
 
 private bool isPrecomposedHangulSylable (Code code) {
     /** whether code is a precomposed Hangul syllable ;-) */
     return (code >= FIRST_HANGUL_SYLLABLE) && (code <= LAST_HANGUL_SYLLABLE);
 }
 
 Thank you,
 Denis
 -- -- -- -- -- -- --
 vit esse estrany ☣
 
 spir.wikidot.com
 
DMD performs inlining as it deems appropriate, but only if the '-inline' switch is provided on the command line. Generally speaking, very simple one-liners like yours will get inlined. -- Chris N-S
Dec 07 2010