Method body from TStringBuilder (Berlin):
Method body from TStringBuilder (Berlin):
function TStringBuilder.Append(const Value: string): TStringBuilder;
begin
Length := Length + System.Length(Value);
Move(PChar(Value)^, FData[Length - System.Length(Value)], System.Length(Value) * SizeOf(Char));
Result := self;
end;
Function Length(Value) is called three times. Is it better would be if string length was calculated once and stored in a local variable?
function TStringBuilder.Append(const Value: string): TStringBuilder;
begin
Length := Length + System.Length(Value);
Move(PChar(Value)^, FData[Length - System.Length(Value)], System.Length(Value) * SizeOf(Char));
Result := self;
end;
Function Length(Value) is called three times. Is it better would be if string length was calculated once and stored in a local variable?
Sometimes caching a simple call can be very important, for example TStreamReader.ReadLine could be 80% faster : https://quality.embarcadero.com/browse/RSP-14620?filter=-2
ReplyDeleteEmbarcadero Summer of Code? :)
ReplyDeleteJacek Laskowski No noticeable improvement here...
ReplyDelete