Author: Uri Blass
Date: 16:13:20 01/01/03
Go up one level in this thread
On January 01, 2003 at 18:58:41, Russell Reagan wrote: >On January 01, 2003 at 18:02:35, Andreas Guettinger wrote: > >>Why is >> >>int x = R[i]; >>if (x == 3 || x == 7) {;} >> >>faster than >> >>if((R[i]==3)||(R[i]==7)) {;} >> >>Isn't the creation and assignment of x a waste of time? > >To get a value of the array element R[i], you have to calculate what spot in >memory that is. It's the same as *(R + i), so there is an extra addition in >there. Maybe that is what he was talking about. Of course, any decent compiler >should be able to optimize this kind of stuff away so it shouldn't matter. In >fact, it shouldn't matter even with no optimization. 1)why it should not matter even with no optimization? Correct me if I am wrong but it seems that with the fastest way you need more memory because you need to remember also x so theoretically it is possible that the computer will crush because of memory problem in the first case when it does not crash in the second case. 2)Suppose that you try optimization for minimize size and not maximal speed Am I correct to assume that the compiler will not define the varaible x? Uri
This page took 0.01 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.