Very interesting:
Very interesting:
function Apples(nb : Integer) : String;
begin
Result := IntToStr(nb) + ' apple(s)';
end;
and
function Apples(nb : Integer) : String;
begin
Result := IntToStr(nb);
Result := Result + ' apple(s)';
end;
Which function faster? ... Second, at least half!
http://www.delphifeeds.com/go/f/109513
function Apples(nb : Integer) : String;
begin
Result := IntToStr(nb) + ' apple(s)';
end;
and
function Apples(nb : Integer) : String;
begin
Result := IntToStr(nb);
Result := Result + ' apple(s)';
end;
Which function faster? ... Second, at least half!
http://www.delphifeeds.com/go/f/109513
Really interesting ... and, emotionally, a bit troubling.
ReplyDeleteDuplicate of
ReplyDeletehttps://plus.google.com/118329774029340938562/posts/9rpY291hMPm
Yes, dup :(
ReplyDeleteKeep in mind the compiler isn't really at fault, it can't optimize the first form to the second without risking (extreme-corner case) side-effects.
ReplyDeletenice trick!
ReplyDelete