Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10 beta 3/9/83; site desint.UUCP Path: utzoo!linus!decvax!ittvax!dcdwest!sdcsvax!sdcrdcf!trwrb!scgvaxd!wlbr!desint!geoff From: geoff@desint.UUCP (Geoff Kuenning) Newsgroups: net.lang.c Subject: Re: Pointers vs. Arrays: an aside about efficiency Message-ID: <139@desint.UUCP> Date: Tue, 9-Oct-84 02:18:49 EDT Article-I.D.: desint.139 Posted: Tue Oct 9 02:18:49 1984 Date-Received: Thu, 4-Oct-84 08:16:07 EDT References: <9224@watmath.UUCP> Organization: his home computer, Thousand Oaks, CA Lines: 25 >>for maximum efficiency, I have to write: >> { struct foo *foop = fooarr; >> for (i=0, i < FOOMAX; i++) >> dostuff(*(foop++)); >> } >>instead of what I mean: >> for (i=0; i < FOOMAX; i++) >> dostuff(fooarr[i]); >> >> Roger Hayes >Only on some machines does the former generate better code....On some >machines, pointer handling (other than just plain indirection) is so >cumbersome that the second piece of code is always better. > Kevin Martin Which is precisely the point. The programmer writing the code can't know what the most efficient method is; the compiler can, and should take advantage of this knowledge to produce better code. Of course, we could always put in #if vax || prime || ... :-) -- Geoff Kuenning First Systems Corporation ...!ihnp4!trwrb!desint!geoff