Browse Source

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

Michaël Van Canneyt 11 months ago
parent
commit
8d5cf6ca5c
2 changed files with 14 additions and 9 deletions
  1. 1 0
      rtl/objpas/classes/classesh.inc
  2. 13 9
      rtl/objpas/classes/stringl.inc

+ 1 - 0
rtl/objpas/classes/classesh.inc

@@ -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);

+ 13 - 9
rtl/objpas/classes/stringl.inc

@@ -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