Re: Efficiency in accessing array elements
From: Grant Edwards (grante_at_visi.com)
Date: 04/30/04
- Next message: Egads: "48ma transceivers that convert 3.3V to 5V ???"
- Previous message: Alan Balmer: "Re: Efficiency in accessing array elements"
- In reply to: Davide: "Efficiency in accessing array elements"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 30 Apr 2004 15:32:19 GMT
On 2004-04-30, Davide <ppp@ppp.it> wrote:
> Is it -in general- more efficient to assign, at the beginning
> of the operation, that element to a local variable (X:=A(K))
> to be used in the rest of the operation instead of using each
> time A(K)?
If you've got a decent compiler, there will be no difference:
the compiler will figure out what values get used most and keep
those values in CPU registers. OTOH, there are some crappy
compilers out there, so it may help to go the local variable
route. The only way to know is to try it and see. In reality
it probably just doesn't matter.
-In general-, write the function in the way that makes the code
easiest to read and maintain. Worry about efficiency of the
function _after_ you've got hard data showing you that your
system performance isn't good enough _and_ it's because of that
function.
--
Grant Edwards grante Yow! I'm a nuclear
at submarine under the
visi.com polar ice cap and I need
a Kleenex!
- Next message: Egads: "48ma transceivers that convert 3.3V to 5V ???"
- Previous message: Alan Balmer: "Re: Efficiency in accessing array elements"
- In reply to: Davide: "Efficiency in accessing array elements"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|