Click here to Skip to main content
15,909,030 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: why visual studio does not optimize constructor in this case Pin
George_George27-Dec-07 4:10
George_George27-Dec-07 4:10 
GeneralRe: why visual studio does not optimize constructor in this case Pin
Maxwell Chen27-Dec-07 4:20
Maxwell Chen27-Dec-07 4:20 
GeneralRe: why visual studio does not optimize constructor in this case Pin
George_George27-Dec-07 16:49
George_George27-Dec-07 16:49 
GeneralRe: why visual studio does not optimize constructor in this case Pin
Maxwell Chen27-Dec-07 4:11
Maxwell Chen27-Dec-07 4:11 
GeneralRe: why visual studio does not optimize constructor in this case Pin
George_George27-Dec-07 16:36
George_George27-Dec-07 16:36 
GeneralRe: why visual studio does not optimize constructor in this case Pin
Maxwell Chen27-Dec-07 17:56
Maxwell Chen27-Dec-07 17:56 
GeneralRe: why visual studio does not optimize constructor in this case Pin
George_George27-Dec-07 18:15
George_George27-Dec-07 18:15 
GeneralRe: why visual studio does not optimize constructor in this case Pin
Sarath C27-Dec-07 4:55
Sarath C27-Dec-07 4:55 
George_George wrote:
RVO rvo;
rvo.mem_var = i;
if (rvo.mem_var == 10)
return (RVO());
return (rvo);


IMHO, In this case the optimization will be difficult and sometimes useless. That may be the reason the code goes untouched.

Suppose the return value pass by hidden reference,as per the article,

1. If value of i == 10, it have to construct/copy the return value once again after initialization as the newly cosntructed object depends on another location of memory. which gives no advantage on optimization

2.As per the article, the NRVO is basically on workes with single return objects.

In the following case, the optimization dint work.

RVO rvo;<br />
	<br />
	if ( 11 == 10)<br />
		return (RVO());<br />
	rvo.mem_var = i;

return (rvo);

In the following case compiler damn sure that
if ( 11 == 10)<br />
    return (RVO());

The above case will never works, so NRVO can be applied but still it's missing I believe.

Anyway I'm not so expert in optimization related things, please share you view points.

-Sarath.
"Great hopes make everything great possible" - Benjamin Franklin

GeneralRe: why visual studio does not optimize constructor in this case Pin
George_George27-Dec-07 16:42
George_George27-Dec-07 16:42 
GeneralRe: why visual studio does not optimize constructor in this case Pin
Sarath C27-Dec-07 19:15
Sarath C27-Dec-07 19:15 
Questioncan anybody explain me the reason for this for loop Pin
Deepu Antony27-Dec-07 2:06
Deepu Antony27-Dec-07 2:06 
AnswerRe: can anybody explain me the reason for this for loop Pin
CPallini27-Dec-07 2:16
mveCPallini27-Dec-07 2:16 
AnswerRe: can anybody explain me the reason for this for loop Pin
PJ Arends27-Dec-07 2:17
professionalPJ Arends27-Dec-07 2:17 
AnswerRe: can anybody explain me the reason for this for loop Pin
David Crow27-Dec-07 2:17
David Crow27-Dec-07 2:17 
GeneralRe: can anybody explain me the reason for this for loop Pin
Deepu Antony27-Dec-07 3:03
Deepu Antony27-Dec-07 3:03 
QuestionHow can i make some EDIT line read only and leave the color of the control in WITHE color ? Pin
Yanshof27-Dec-07 1:50
Yanshof27-Dec-07 1:50 
AnswerRe: How can i make some EDIT line read only and leave the color of the control in WITHE color ? Pin
David Crow27-Dec-07 2:07
David Crow27-Dec-07 2:07 
GeneralRe: How can i make some EDIT line read only and leave the color of the control in WITHE color ? Pin
Yanshof27-Dec-07 2:33
Yanshof27-Dec-07 2:33 
GeneralRe: How can i make some EDIT line read only and leave the color of the control in WITHE color ? Pin
David Crow27-Dec-07 2:40
David Crow27-Dec-07 2:40 
AnswerRe: How can i make some EDIT line read only and leave the color of the control in WITHE color ? Pin
CPallini27-Dec-07 2:14
mveCPallini27-Dec-07 2:14 
GeneralReading a file - only the updated entries Pin
int01h27-Dec-07 1:36
int01h27-Dec-07 1:36 
GeneralRe: Reading a file - only the updated entries Pin
CPallini27-Dec-07 1:59
mveCPallini27-Dec-07 1:59 
QuestionRe: Reading a file - only the updated entries Pin
David Crow27-Dec-07 2:19
David Crow27-Dec-07 2:19 
GeneralRe: Reading a file - only the updated entries Pin
CPallini27-Dec-07 2:47
mveCPallini27-Dec-07 2:47 
GeneralOCR Pin
sujtha27-Dec-07 0:54
sujtha27-Dec-07 0:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.