🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #2488

Re: pointers for speed

#2488
From: Christopher R Volpe
Date: Tue, 26 Feb 1991 14:18
25 lines
1325 bytes
In article <955@caslon.cs.arizona.edu>, dave@cs.arizona.edu (Dave P.
Schaumann) writes:
|>In article <1998@gold.gvg.tek.com> shaunc@gold.gvg.tek.com (Shaun
Case) writes:
|>>I know that when you repeatedly access something like
|>>
|>>foo.a.b.c.d[11].value
|>>
|>>it is better to declare a (register) pointer, assign it the address
|>>of foo.a.b.c.d[11].value, and do manipulations on that, since it
|>>is faster.
|>
|>Oh really?  Seems to me that &foo.a.b.c.d[0] is a constant that can be
|>computed *at compile time*.  

Oh really? What if the type of "foo.a.b.c.d" is "struct bar *" and you
initialize it with:
    foo.a.b.c.d = (struct bar *) malloc(15 * sizeof(struct bar));

Then neither &foo.a.b.c.d[0] nor &foo.a.b.c.d[11] are compile time
constants.                        
==================
Chris Volpe
G.E. Corporate R&D
volpecr@crd.ge.com
Technical Details
Message-ID: <17114@crdgw1.crd.ge.com>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uwm.edu!rpi!crdgw1!camelback!volpe
References: <1998@gold.gvg.tek.com> <955@caslon.cs.arizona.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uwm.edu!rpi!crdgw1!camelback!volpe
From: volpe@camelback.crd.ge.com (Christopher R Volpe)
Newsgroups: comp.std.c
Subject: Re: pointers for speed
Message-ID: <17114@crdgw1.crd.ge.com>
Date: 26 Feb 91 14:18:38 GMT
References: <1998@gold.gvg.tek.com> <955@caslon.cs.arizona.edu>
Sender: news@crdgw1.crd.ge.com
Reply-To: volpe@camelback.crd.ge.com (Christopher R Volpe)
Lines: 25