title: Removing duplicate lines from TStringList without sorting in Delphi
body: <p>I know how to remove duplicate strings from a TStringList  using dupignore for a sorted Tstringlist.</p>
  
  <pre><code>CallData := TStringList.Create;
  CallData.Sorted := True;
  Call.Duplicates := dupIgnore;
  </code></pre>
  
  <p><strong>But in my case strings must not be sorted</strong> .</p>
  
  <p>Using a FOR loop finding duplicates is very slow (also using indexOF())when TStringList has hundreds of thousands of lines .</p>
  
  <pre><code> if OpenDialog1.Execute then
    begin
      Try
        y := TStringList.create;
        f := TStreamReader.create(OpenDialog1.FileName, TEncoding.UTF8, True);
        while not f.EndOfStream do
        begin
          l := f.ReadLine;
          X.Add(l);
        end;
  
        g := Tstreamwriter.create('d:\logX.txt', True, TEncoding.UTF8);
        for I := 0 to X.count - 1 do
        begin
  
  
            if y.IndexOf(X[I]) = -1 then
  
            y.Add(X[I]);
  
        end;
  
        for j := 0 to y.count - 1 do
          g.WriteLine(y[j]);
  
      Finally
        f.free;
        y.free;
        g.free;
      End;
    end;
  </code></pre>
  
  <p>is there any better way ?</p>