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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Tell whether a primitive subprogram was overridden Date: Tue, 19 Aug 2014 15:57:52 +0200 Organization: cbb software GmbH Message-ID: <17wr6psgtju81$.vcio92x50jpn$.dlg@40tude.net> References: <1nlld44wut4kf.1l1mtjf7durro.dlg@40tude.net> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: yj8+JIQUMOEawvIM7K49kA.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 Xref: news.eternal-september.org comp.lang.ada:21830 Date: 2014-08-19T15:57:52+02:00 List-Id: On Tue, 19 Aug 2014 16:45:54 +0300, Victor Porton wrote: > Dmitry A. Kazakov wrote: >> You mean that a check would be more efficient than a dispatching call? I >> don't think there would be much difference, except the case when the >> subprogram has a long list of additional arguments or computed arguments. >> That is usually the case when doing tracing stuff. In that case you could >> think of some lazy parameter evaluation schema or upfront checks as Adam >> suggested. > > No. I haven't described exactly what I do. > > I need to register (by calling a C function) a C wrapper around a method of > my class as a callback subprogram. If my method is null, it is not necessary > to register it and the C code would not call it. You certainly register it only once. Therefore it is indeed the overhead of a single dispatching call = a couple of nanoseconds. If you are in this area you should look at C code as well. It checks if something is registered. The depending on the choice it does a jump or no jump. Jump is also a nanosecond of so. Morale: premature optimization is the root of all evil. [ And you never know if what you are doing would make the code faster, until you measure it. ] -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de