One more variant: "Original split - optimized"
First case (VERY long string):
Code:
928 (total items: 110121) - Original split
64 (total items: 110110) - DelimitedText split
427 (total items: 110121) - Harry Hunt split
62 (total items: 110121) - Original split - optimized (!)
Second case (MANY average strings):
Code:
125 (total items: 111111) - Original split
66 (total items: 110110) - DelimitedText split
405 (total items: 111111) - Harry Hunt split
64 (total items: 111111) - Original split - optimized (!)
:lol: :lol: :lol: :lol: :lol: :lol:
CODE:
[pascal]
function TForm1.Split_4(const Source, Delimiter: String): TStringList;
var
DelLength: Integer;
SearchPos, FoundAt: Integer;
begin
Result := TStringList.Create;
DelLength:= Length(Delimiter);
SearchPos:= 1; // initialize it
FoundAt:= PosEx(Delimiter, Source, SearchPos);
while FoundAt > 0 do
begin
Result.Add(Copy(Source, SearchPos, FoundAt - SearchPos));
SearchPos:= FoundAt + DelLength;
FoundAt:= PosEx(Delimiter, Source, SearchPos);
end;
Result.Add(Copy(Source, SearchPos, MaxInt));
end;
[/pascal]
Bookmarks