Re: reference VS. pointer
From: Peter van Merkerk (merkerk_at_deadspam.com)
Date: 12/05/03
- Next message: Victor Bazarov: "Re: Concept of nested classes"
- Previous message: Dan W.: "Re: A different kind of adaptor iterator"
- In reply to: Ron Natalie: "Re: reference VS. pointer"
- Next in thread: Gianni Mariani: "Re: reference VS. pointer"
- Reply: Gianni Mariani: "Re: reference VS. pointer"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 5 Dec 2003 20:45:52 +0100
"Ron Natalie" <ron@sensor.com> wrote in message
news:3fd0dcc8$0$7506$9a6e19ea@news.newshosting.com...
>
> "calvin" <calvinlh@operamail.com> wrote in message
news:3824dd66.0312051115.15c94b32@posting.google.com...
>
> > int i = 12;
> > int& r = i;
> > int* p = &i;
> >
> > the memory lay-out would look like,
>
> Not necessarily.
>
> >
> > Surprisingly, when I wrote a short program to verify this, I got
> > totally reversed result. The pointer is faster than reference!
> > My test is based on GCC 3.2 on a W2K system.
> >
> > Replies are appreciated.
>
> Lets see your test program. Also did you turn on the optimizer?
> There is no point in benchmarking most compiler performances in the
> unoptimized mode.
Also when the optimizer is on, there is big chance it doesn't matter whether
you use pointers or references. A good exercise is to study the assembly
output of an optimizing compiler; one of the most important lessons one will
learn is that that those nano optimizations are futile; in many cases they
have no effect whatsoever.
-- Peter van Merkerk peter.van.merkerk(at)dse.nl
- Next message: Victor Bazarov: "Re: Concept of nested classes"
- Previous message: Dan W.: "Re: A different kind of adaptor iterator"
- In reply to: Ron Natalie: "Re: reference VS. pointer"
- Next in thread: Gianni Mariani: "Re: reference VS. pointer"
- Reply: Gianni Mariani: "Re: reference VS. pointer"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|