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,1d485db3760413be X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-10-18 02:50:33 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!newsfeed.cwix.com!news.binc.net!kilgallen From: Kilgallen@SpamCop.net (Larry Kilgallen) Newsgroups: comp.lang.ada Subject: Re: Compiler default initialization of array types Date: 18 Oct 2002 04:50:30 -0500 Organization: LJK Software Message-ID: References: NNTP-Posting-Host: eisner.encompasserve.org X-Trace: grandcanyon.binc.net 1034934623 20261 192.135.80.34 (18 Oct 2002 09:50:23 GMT) X-Complaints-To: abuse@binc.net NNTP-Posting-Date: Fri, 18 Oct 2002 09:50:23 +0000 (UTC) Xref: archiver1.google.com comp.lang.ada:29895 Date: 2002-10-18T04:50:30-05:00 List-Id: In article , Robert A Duff writes: > I have written code where there were lots of giant arrays of pointers, > inside a record with another component indicating how many are valid. > Something like: > > type T is > record > Last: Natural := 0; > Pointers: Pointer_Array(1..Big_Number); > > Typically, objects of type T would use just a few pointers -- like Last > might be 3 or 4, but very unusual for it to be 1000 or 1_000_000. > > It turned out that initializing all those unused pointers to null was a > serious performance problem. So I cheated: I declared the array as an > array of integers (where the integer type was chosen to be the same size > as a pointer), and used unchecked_conversion. Efficiency will depend on the compiler and potentially the operating system. For package-level data on VMS, compilers that need a lot of zeroed memory will typically emit linker instructions to "fake it" with manipulation of the memory management system. > It would also help if the OP explained why default-init is > undesirable. Efficiency? Interfacing to objects initialized in some > other language, or by hardware?