diff --git a/lcl/textstrings.pas b/lcl/textstrings.pas index 2c3d75a7b6..82691f2bb7 100644 --- a/lcl/textstrings.pas +++ b/lcl/textstrings.pas @@ -35,6 +35,7 @@ type Line: string; // cached line as string TheObject: TObject; // user data end; + PTextLineRange = ^TTextLineRange; TTextStrings = class(TStrings) private @@ -44,7 +45,7 @@ type FArraysValid: boolean; FLineCount: integer; FLineCapacity: integer; - FLineRanges: ^TTextLineRange;// array of TTextLineRange + FLineRanges: PTextLineRange;// array of TTextLineRange FText: string; FUpdateCount: integer; FChangedWhileUpdate: boolean; @@ -61,7 +62,6 @@ type procedure PutObject(Index: Integer; AnObject: TObject); override; function GetLineLen(Index: integer; IncludeNewLineChars: boolean): integer; inline; function GetLineEnd(Index: integer; IncludeNewLineChars: boolean): integer; - function HasObjects: boolean; function CountLineEndings(const s: string): integer; public constructor Create; @@ -169,16 +169,18 @@ begin end; function TTextStrings.Get(Index: Integer): string; +var + Line: PTextLineRange; begin if not FArraysValid then BuildArrays; if (Index<0) or (Index>=FLineCount) then Error(rsListIndexExceedsBounds, Index); - if (FLineRanges[Index].Line='') - and (FLineRanges[Index].StartPosnil then - exit(true); - Result:=false; -end; - function TTextStrings.CountLineEndings(const s: string): integer; var p: Integer; @@ -691,40 +682,22 @@ begin end; procedure TTextStrings.AddStrings(TheStrings: TStrings); - - function MustAddObjects: boolean; - var - i: Integer; - begin - if HasObjects then exit(true); - if TheStrings is TTextStrings then - Result:=TTextStrings(TheStrings).HasObjects - else - begin - for i:=0 to TheStrings.Count-1 do - if TheStrings.Objects[i]<>nil then - exit(true); - Result:=false; - end; - end; - var s: String; i: Integer; + OldCount: Integer; begin if TheStrings.Count=0 then exit; - if MustAddObjects then - begin - for i:=0 to TheStrings.Count-1 do - AddObject(TheStrings[i],TheStrings.Objects[i]); - end else begin - if (FText<>'') and (not (FText[length(FText)] in [#10,#13])) then - s:=LineEnding - else - s:=''; - FArraysValid:=false; - FText:=FText+s+TheStrings.Text; - end; + OldCount:=Count; + if (FText<>'') and (not (FText[length(FText)] in [#10,#13])) then + s:=LineEnding + else + s:=''; + FArraysValid:=false; + FText:=FText+s+TheStrings.Text; + BuildArrays; + for i:=0 to TheStrings.Count-1 do + FLineRanges[i+OldCount].TheObject:=TheStrings.Objects[i]; end; end.