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?

Comments

  1. 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

    ReplyDelete
  2. Embarcadero Summer of Code? :)

    ReplyDelete
  3. Jacek Laskowski No noticeable improvement here...

    ReplyDelete

Post a Comment