Quantcast
Channel: Visual C forum
Viewing all articles
Browse latest Browse all 15302

C/C++ reference/pointer speed

$
0
0

Hello,

Im working on a potentially large project, with OpenGL. I access model data through arrays of arrays (pointers to pointers).

However, I questioned myself wether to use this or one large array, since I presume pointers to pointers require twice lookup? I really doubt about this and Im not sure wether to use arrays of arrays (easier to read) or one pointer/array.

Futhermore, is using pointers slower than using the variable?

eg:

int a, *b;

b = new int;

a = 1;

*b = 1; // does this have a difference in speed?

If I call a variable, like above here a = 1, what happens? I go to memory of a and change the bits to value "1"?

So if this is true, then in principle *b is just the same, but different for the compiler? I just use the address given by b to access that memory and do the same as with variable a? These things are properties for compiler right? when I type a = ... or c = a + sth then when I call a, I get he value, so isn't "a" just *(&a) ? So as I asked, are pointers / references slower?


Viewing all articles
Browse latest Browse all 15302

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>