Steve Maughan 26 Posted February 25, 2021 I have a confession: I'm terrible at ensuring there are no Hints or Warnings in my code. That's all got to stop now that I have switched to 10.4.2 — the IDE now scream at me to fix these Hint and Warning (that's a good thing)! One hint that crops up a lot in my code is H2443 Inline function. Typically it says something like: H2443 Inline function: TOptimizer.Execute has been expanded because unit 'TAnneal' is not included in the USES list What is this all about? Clearly the code runs without TAneal in the USES list and I like to minimize the number of units in the USES list. The hint goes away if I add TAnneal to the USES list but what's the advantage of including it — my code is cleaner and runs just fine if I don't include it. Also, does anyone have a tutorial on getting rid of Delphi Hints and Warnings? Some are obvious, others (like this one) are not so obvious. Thanks, Steve Share this post Link to post
Anders Melander 1782 Posted February 25, 2021 38 minutes ago, Steve Maughan said: What is this all about? Did you start by reading the help? Share this post Link to post
FredS 138 Posted February 25, 2021 46 minutes ago, Steve Maughan said: Clearly the code runs without TAneal in the USES list and I like to minimize the number of units in the USES list. Right, it will simply NOT inline that function and that means there is a Jump.. inline is faster.. ..more on those for Rio Share this post Link to post
Steve Maughan 26 Posted February 25, 2021 19 minutes ago, Anders Melander said: Did you start by reading the help? Thanks! Share this post Link to post
Steve Maughan 26 Posted February 25, 2021 10 minutes ago, FredS said: Right, it will simply NOT inline that function and that means there is a Jump.. inline is faster.. ..more on those for Rio So it's a speed thing. Thanks! Share this post Link to post
Arnaud Bouchez 407 Posted February 25, 2021 Side note: inlining is not necessary faster. Sometimes, after inlining the compiler has troubles assigning properly the registers: so a sub-function with a loop is sometimes faster when NOT inlined, because the loop index and pointer could be in a register, whereas once inlined the stack may be used. The worse use of "inline;" I have seen is perhaps the inlining of FileCreate/FileClose/DeleteFile/RenameFile from SysUtils which required the Windows unit to be part of any unit calling it. With obviously no performance benefit because those calls are slow by nature. Embarcadero made this mistake in early versions of Delphi, then they fixed some of it (but RenameFile is still inlined!), and re-used "inline;" when POSIX was introduced... 😞 I had to redefine those functions in mormot.core.os.pas so that I was not required to write {$ifdef MsWindows} Windows, {$endif} in my units when writing cross-platform code... 1 Share this post Link to post
Fr0sT.Brutal 900 Posted February 26, 2021 (edited) 16 hours ago, Arnaud Bouchez said: Embarcadero made this mistake in early versions of Delphi, then they fixed some of it (but RenameFile is still inlined!), and re-used "inline;" when POSIX was introduced... 😞 I've never seen FileCreate/FileClose inlined; DeleteFile is inlined for Posix and yes, RenameFile is still inlined for all platforms (checking in XE2 and 10.3). Odd decision really. The worse thing with inlines is that they can't use internal constants 😞 Edited February 26, 2021 by Fr0sT.Brutal Share this post Link to post