From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,e169af38f0a27bda X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-02-23 10:07:18 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!headwall.stanford.edu!newsfeed.news2me.com!newsfeed2.easynews.com!newsfeed1.easynews.com!easynews.com!easynews!newsfeed1.earthlink.net!newsfeed.earthlink.net!stamper.news.pas.earthlink.net!newsread2.prod.itd.earthlink.net.POSTED!not-for-mail Message-ID: <3E590DC1.5000005@acm.org> From: Jeffrey Carter User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.0.0) Gecko/20020530 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: When shoul Pragma Inline be used? References: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Date: Sun, 23 Feb 2003 18:07:21 GMT NNTP-Posting-Host: 63.184.0.125 X-Complaints-To: abuse@earthlink.net X-Trace: newsread2.prod.itd.earthlink.net 1046023641 63.184.0.125 (Sun, 23 Feb 2003 10:07:21 PST) NNTP-Posting-Date: Sun, 23 Feb 2003 10:07:21 PST Organization: EarthLink Inc. -- http://www.EarthLink.net Xref: archiver1.google.com comp.lang.ada:34481 Date: 2003-02-23T18:07:21+00:00 List-Id: Preben Randhol wrote: > > I just wonder when one should use Pragma Inline and when one should not > use it. If somebody could give some tips/links it would be very helpful. > > Example: > > package body Settings is > > function Filename > return String > is > begin > return To_String (Current_File_Settings.File_Name); > end Filename; > > procedure Set_Filename > (Name : String) > is > begin > Current_File_Settings.File_Name := To_Unbounded_String (Name); > end Set_Filename; > > end Settings; > > Here is makes sense to add Pragma Inline (Filename); ? But what about > the Set_Filename (Name : String)? Should this also be Inline? Inline allows you to indicate that you are willing to accept potentially larger executable size and increased module coupling in exchange for the speed increase of eliminating subprogram calls. If you inline these subprograms, it's because you are using them, or think they may someday be used, in situations where the overhead of the subprogram call is unacceptable. Since you're using Unbounded_String, it's unlikely that these subprograms would be acceptable in such situations with or without inlining. A general rule I learned is: Inline small subprograms if your program has tight time constraints. "Small" is not precisely defined; you have to decide how many statements is too many. Some compilers will automatically inline calls to small subprograms. Such compilers must have a precise definition of "small", probably based on the size of the object code. At 1 statement each, I would think these subprograms meet any reasonable definition of "small". Whether your program has tight timing constraints you don't say. It won't hurt to inline these subprograms, but I doubt it will help noticeably, either. -- Jeff Carter "Spam! Spam! Spam! Spam! Spam! Spam! Spam! Spam!" Monty Python's Flying Circus