From: Kilgallen@SpamCop.net (Larry Kilgallen)
Subject: Re: Compiler default initialization of array types
Date: 18 Oct 2002 04:50:30 -0500
Date: 2002-10-18T04:50:30-05:00 [thread overview]
Message-ID: <LLvXOWdDrhx6@eisner.encompasserve.org> (raw)
In-Reply-To: wcc3cr4vcti.fsf@shell01.TheWorld.com
In article <wcc3cr4vcti.fsf@shell01.TheWorld.com>, Robert A Duff <bobduff@shell01.TheWorld.com> 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?
next prev parent reply other threads:[~2002-10-18 9:50 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-10-17 12:55 Compiler default initialization of array types Sebastian
2002-10-17 13:10 ` Lutz Donnerhacke
2002-10-17 22:39 ` Peter Richtmyer
2002-10-17 13:42 ` Matthew Heaney
2002-10-17 23:57 ` Robert A Duff
2002-10-18 9:50 ` Larry Kilgallen [this message]
2002-10-18 14:40 ` Robert A Duff
2002-10-18 15:04 ` Larry Kilgallen
2002-10-18 13:36 ` Matthew Heaney
2002-10-18 15:28 ` Wes Groleau
-- strict thread matches above, loose matches on Subject: below --
2002-10-17 14:23 Grein, Christoph
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox