speed, baby!

Started by
8 comments, last by untalkative_monkey 22 years, 3 months ago
Hey, does anybody know? Are references slower or faster than pointers when being passed to functions? And I''m told that using 32-bit (int) variables is best for some reason... is this true? Why? Does this mean that i shouldnt even use bool variables to set simple flags? ...go on and live with no regrets, you only have one life...
...go on and live with no regrets, you only have one life...
Advertisement
References basically are pointers. Look at the assembly code produced by each. 32bit variables are fastest for 32bit processors. I still use single byte boolean variables when I only need to store a true/false value since I obviously won''t be doing a lot of work with any such variable (It''s not as if you''re doing math with them ).

[Resist Windows XP''s Invasive Production Activation Technology!]
thanks a lot... but i like to lay off looking at assembly code.. makes me nautious. :p

...go on and live with no regrets, you only have one life...
...go on and live with no regrets, you only have one life...
If you are wanting to send simple true/false flags, then use a 32 bit integer, and have each flag represent one bit. Then just OR together the flags you want, and you can send up to 32 flags with one variable. Much faster then a load of bool''s.
heeeyyyyyy, thats true, i''ll do that if i ever need more than a few flags... thanks to you too.

...go on and live with no regrets, you only have one life...
...go on and live with no regrets, you only have one life...
But is there any point of using pointers at all if you know the size of the data you what to store?
quote:Original post by ToxicSoul
But is there any point of using pointers at all if you know the size of the data you what to store?

Yes.

[Resist Windows XP''s Invasive Production Activation Technology!]
I saw it somewhere in a book or website that references were
slightly faster than pointers. They had graphs of speed and
such. Look it up.
"thanks a lot... but i like to lay off looking at assembly code..
makes me nautious. :p"

What??? You mean you don''t convert the C/C++ to asm in
your head as you write it?
quote:Original post by Anonymous Poster
I saw it somewhere in a book or website that references were
slightly faster than pointers. They had graphs of speed and
such. Look it up.

They were horribly mistaken (or your misinterpreted what they were saying). I just ran a test (although I personally didn''t need to see it) and they were exactly the same speed. If you want the source, I''ll post it (it''s short, but not so short that I''d post it without need to ).

[Resist Windows XP''s Invasive Production Activation Technology!]

This topic is closed to new replies.

Advertisement