On Sunday 24 November 2013 14:55:03 Ivanko B wrote:
> := result;
>
> =====================
> Will it cause extra memory copying if function returns a class instance etc
> ?
>
A class instance is a pointer -> not expensive to copy?
It could be optimized to use the assignment destination address directly if it
is a simple assignment. With 'return' variable this is not possible because
the result can be input too. Without intermediate variable:
"
function test(const para: string): string;
begin
result:= '12345678'; //original str1 is released,
//para points to invalid memory
result:= result+para; //bang!
end;
var
str1: string;
...
str1:= 'abc';
str1:= test(str1);
"
Martin
------------------------------------------------------------------------------
Shape the Mobile Experience: Free Subscription
Software experts and developers: Be at the forefront of tech innovation.
Intel(R) Software Adrenaline delivers strategic insight and game-changing
conversations that shape the rapidly evolving mobile landscape. Sign up now.
http://pubads.g.doubleclick.net/gampad/clk?id=63431311&iu=/4140/ostg.clktrk
_______________________________________________
mseide-msegui-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk