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=unavailable autolearn_force=no version=3.4.4 Path: border1.nntp.dca3.giganews.com!border2.nntp.dca3.giganews.com!border4.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: Optimizing Ada Date: Wed, 02 Oct 2013 08:16:02 +0100 Organization: A noiseless patient Spider Message-ID: References: <8aca502c-bba8-4af5-9192-459c15fe048b@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx05.eternal-september.org; posting-host="efa74e8377ee8d65bf4cce5dc399bc92"; logging-data="28059"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19OYaEuKJ7Z6zcEMjiuKzL0RRL8QVdO0Zo=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (darwin) Cancel-Lock: sha1:t7a6sn3qidHrEe9XHOf9SAyfFCE= sha1:fBdQz13at5yht40OxQ+V1EspIXw= X-Original-Bytes: 2289 Xref: number.nntp.dca.giganews.com comp.lang.ada:183567 Date: 2013-10-02T08:16:02+01:00 List-Id: kennethesills@gmail.com writes: > So I was just wondering if anyone could help me optimize my Ada code a > bit, as well as tell me how I'm doing in terms of general code style > and idiomatic code writing. Looks pretty good to me (we disagree about having a space between the subprogram name and the opening paren, but then the ALRM is wrong about that too :-) I'm not sure that pragma Inline is meant to work when applied to a subprogram body, so I'd apply it to the spec (I always write specs, because I've set the GNAT style options to standard (-gnaty), and that warns me about missing specs - and about missing spaces, see above). GNAT may not have implemented your Inline anyway. There's a GNAT pragma Inline_Always, and there are switches (-gnatn, -gnatN I think) that affect inlining. The last time I did a check, inlining made my program slower - cache effects, presumably. That was on powerpc. AdaCore's house rules don't allow I as a variable name (confusion potential), they start at J. I wonder whether your performance problem is caused by using a function? The internal Word_Map is, I think, going to be copied to the destination and then finalized. Could you use an out parameter? (remembering to clear it before adding ne new content).