* Alternative approach for AddObject, which does not break backwards compatibility. Fixes issue #40899

This commit is contained in:
Michaël Van Canneyt 2024-08-22 08:33:34 +02:00
parent 2f0cd77d86
commit 8d5cf6ca5c
2 changed files with 14 additions and 9 deletions

View File

@ -1134,6 +1134,7 @@ type
procedure InsertItem(Index: Integer; const S: string); virtual;
procedure InsertItem(Index: Integer; const S: string; O: TObject); virtual;
Function DoCompareText(const s1,s2 : string) : PtrInt; override;
function DoAddObject(const S: string; AObject: TObject) : Integer; inline;
public
Constructor Create;
Constructor Create(anOwnsObjects : Boolean);

View File

@ -1935,15 +1935,7 @@ begin
Inherited destroy;
end;
function TStringList.Add(const S: string): Integer;
begin
Result := AddObject(S, nil);
end;
function TStringList.AddObject(const S: string; AObject: TObject): Integer;
function TStringList.DoAddObject(const S: string; AObject: TObject): Integer;
begin
If (SortStyle<>sslAuto) then
@ -1957,6 +1949,18 @@ begin
InsertItem (Result,S,AObject);
end;
function TStringList.Add(const S: string): Integer;
begin
Result:=DoAddObject(S, nil);
end;
function TStringList.AddObject(const S: string; AObject: TObject): Integer;
begin
Result:=DoAddObject(S,aObject);
end;
procedure TStringList.Clear;
begin