Skip to main content
gamedev.net
🔒 Locked

Reference & Pointer :: C++

Started by kuphryn 3 replies 400+ views
Original Post
kuphryn
kuphryn
Performancewise, is it better to pass by reference or pass by pointer if applicable? Thanks, Kuphryn
xgalaxy
xgalaxy
They are very much alike actually. I don''t really see any performance difference at all.
DrPizza
DrPizza
References are generally (always?) implemented as pointers anyway.
char a[99999],*p=a;int main(int c,char**V){char*v=c>0?1[V]:(char*)V;if(c>=0)for(;*v&&93!=*v;){62==*v&&++p||60==*v&&--p||43==*v&&++*p||45==*v&&--*p||44==*v&&(*p=getchar())||46==*v&&putchar(*p)||91==*v&&(*p&&main(0,(char**)(--v+2))||(v=(char*)main(-1,(char**)++v)-1));++v;}else for(c=1;c;c+=(91==*v)-(93==*v),++v);return(int)v;} /*** drpizza@battleaxe.net ***/
kuphryn
kuphryn
Interesting. Thanks.

Kuphryn
untalkative_monkey
untalkative_monkey
Someone in these forums, I don''t remember who, told me that if you look at the assembly generated by pointers and references, they are pretty much identical. I didn''t look personally, but...

...go on and live with no regrets, you only have one life...
...go on and live with no regrets, you only have one life...

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.