Article View: comp.os.msdos.programmer
Article #6652Re: Very puzzling struct problem!
From: Fuzzy Fox
Date: Mon, 23 Nov 1992 19:55
Date: Mon, 23 Nov 1992 19:55
19 lines
1330 bytes
1330 bytes
ematias@csri.toronto.edu (Ummm... me!) writes: > This is totally baffling me, since I can't comprehend why my program >would be BIGGER and SLOWER just because the number of elements in a struct >isn't a multiple of 16 -- and furthermore, why it works fine for only >a select few multiples of 16. Help! It is because pointer arithmetic is more efficient with powers of two. If the size of your struct is a power of two, then pointer manipulations (and array offset calculations) can be performed with simple shift instructions, whereas non-power-of-two-sized elements require slow multiply and division operations, which both increase the size of your code and slow down the program. Exactly what you observed. -- #ifdef TRUE | Fuzzy Fox (a.k.a. David DeSimone) fuzzy@netcom.com #define TRUE 0 | #define FALSE 1 | "You have been recruited by the Star League to defend #endif | the Frontier against Xur and the Kodan Armada."
Technical Details
Message-ID:
<1992Nov23.195509.8376@rei.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!rei2!foxReferences:
<1992Nov21.221745.23588@jarvis.csri.toronto.edu>Show Full Headers
Complete Article Headers
Newsgroups: comp.os.msdos.programmer Path: arc1-ca.pugleaf.net!sparky!uunet!rei2!fox From: fox@rei.com (Fuzzy Fox) Subject: Re: Very puzzling struct problem! Message-ID: <1992Nov23.195509.8376@rei.com> Date: Mon, 23 Nov 1992 19:55:09 GMT References: <1992Nov21.221745.23588@jarvis.csri.toronto.edu> Organization: Recognition Equipment, Inc. Lines: 19