Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6049379
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:34:13+00:00 2026-05-23T07:34:13+00:00

I was tying to optimize a piece of code that has this construct: while

  • 0

I was tying to optimize a piece of code that has this construct:

while (i > 0) do begin
  Dec(i);

This looks inefficient, so I tried to do this:

while (Dec(i) >= 0) do begin

That doesn’t work because Dec is a procedure and not a function.

So I rewrite it to:

procedure Withloop;
var
  ....
  function Decr(var a: integer): integer; inline;
  begin
    Dec(a);
    Result:= a;
  end;

...
  while (Decr(i) >= 0) do begin

But this gets compiled into:

SDIMAIN.pas.448: while (Decr(i) >= 0) do begin
00468EE5 8BC4             mov eax,esp
00468EE7 E8D0FEFFFF       call Decr          <<--- A call??
00468EEC 85C0             test eax,eax
00468EEE 0F8D12FFFFFF     jnl $00468e06
00468EF4 EB01             jmp $00468ef7

However in another part of the program, it inlines a function just fine.
What rule of thumb (or hard rule) can I use to know to Delphi will honor the inline directive?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T07:34:14+00:00Added an answer on May 23, 2026 at 7:34 am

    The Delphi Documentation enumerates the conditions under which inlining does or does not occur:

    • Inlining will not occur on any form of late-bound method. This includes
      virtual, dynamic, and message methods.
    • Routines containing assembly code will not be inlined.
    • Constructors and destructors will not be inlined.
    • The main program block, unit initialization, and unit finalization
      blocks cannot be inlined.
    • Routines that are not defined before use cannot be inlined.
    • Routines that take open array parameters cannot be inlined.
    • Code can be inlined within packages, however, inlining never occurs across
      package boundaries.
    • No inlining is done between units that are circularly dependent. This
      includes indirect circular
      dependencies, for example, unit A uses
      unit B, and unit B uses unit C which
      in turn uses unit A. In this example,
      when compiling unit A, no code from
      unit B or unit C will be inlined in
      unit A.
    • The compiler can inline code when a unit is in a circular dependency, as
      long as the code to be inlined comes
      from a unit outside the circular
      relationship. In the above example, if
      unit A also used unit D, code from
      unit D could be inlined in A, since it
      is not involved in the circular
      dependency.
    • If a routine is defined in the interface section and it accesses
      symbols defined in the implementation
      section, that routine cannot be
      inlined.
    • If a routine marked with inline uses external symbols from other units, all
      of those units must be listed in the
      uses statement, otherwise the routine
      cannot be inlined.
    • Procedures and functions used in conditional expressions in while-do
      and repeat-until statements cannot be
      expanded inline.
    • Within a unit, the body for an inline function should be defined
      before calls to the function are made.
      Otherwise, the body of the function,
      which is not known to the compiler
      when it reaches the call site, cannot
      be expanded inline.

    In your case check this condition:

    Procedures and functions used in conditional expressions in while-do and repeat-until statements cannot be expanded inline.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to optimize a small piece of code with SSE intrinsics (I
I'm trying to build a Chrome browser extension, that should enhance the way the
I have a project that adds elements to an AutoCad drawing. I noticed that
I have found this example on StackOverflow: var people = new List<Person> { new
I'm currently stuck on trying to make a naive algorithm which given a piece
I'm trying to optimize my Galleria module for Drupal 7. Everything goes OK except
I'm trying to optimize some of the user facing parts of my app by
I have written a feed aggregator before but am trying to optimize it a
I'm pretty strong with SQL, but I can't think of good solution to this
I am trying to implement a search algorithm in my simple datastructure. However, this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.