T
Thorsten Kiefer
Hi,
following issue :
class X {
//very complicated and memory intensive stuff
];
inline X operation(const X &a,const X &b){
X c;
c = ....a....b....; // some operation
return c;
}
main(){
X s,t,v;
v = operation(s,t);
}
My question:
The function "operation" creates an instance of X, operates on it, copies it
into the return buffer and destroys it. Then the return buffer is copied
into v.
Can the optimizer optimize this such that "operation" operates directly on v
instead of an intermediate instance of X ?
I guess this would be a huge performance increase, wouldn't it ?
Regards
Thorsten
following issue :
class X {
//very complicated and memory intensive stuff
];
inline X operation(const X &a,const X &b){
X c;
c = ....a....b....; // some operation
return c;
}
main(){
X s,t,v;
v = operation(s,t);
}
My question:
The function "operation" creates an instance of X, operates on it, copies it
into the return buffer and destroys it. Then the return buffer is copied
into v.
Can the optimizer optimize this such that "operation" operates directly on v
instead of an intermediate instance of X ?
I guess this would be a huge performance increase, wouldn't it ?
Regards
Thorsten