25 Oct
2006
25 Oct
'06
12:37 a.m.
-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Peng Yu Sent: Tuesday, October 24, 2006 5:33 PM Does it mean that code segment 1 is as fast as segment 2, but code segment 3 is the slowest?
///////1 boost::shared_array a(new int[100]); for(int i = 0; i < 100; ++ i) a.get()[i] = i;
////////2 boost::shared_array a(new int[100]); int a_ptr = a.get(); for(int i = 0; i < 100; ++ i) a_ptr[i] = i;
////////3 boost::shared_array a(new int[100]); for(int i = 0; i < 100; ++ i) a[i] = i;
All I can say is profile, profile, profile! PS: Profile. PPS: I'd guesstimate with a proper C++ compiler + optimizer, you wouldn't notice much of a difference between 1 and 3.