![]() |
Re: Trim dauert bis zu 5 minuten....Benötige schnelle Lösung
Versuch es mal hiermit:
Delphi-Quellcode:
Braucht für ne 12MB Textdatei ca. 250 ms.
type
TMyStringList = class(TStringList) private FCount: Integer; public constructor Create; function Add(const S: string): Integer; override; property TrueLineCount: Integer read FCount write FCount; end; constructor TMyStringList.Create; begin FCount := 0; end; function TMyStringList.Add(const S: string): Integer; begin if (Trim(S) = EmptyStr) then Result := -1 else begin Result := inherited Add(S); Inc(FCount); end; end; |
Re: Trim dauert bis zu 5 minuten....Benötige schnelle Lösung
Um Festzustellen, ob eine Zeile leer ist reicht es aus, TrimRight() zu verwenden.
TrimRight() ist schneller als Trim(), da die Funktion weniger zu tun hat. Noch schneller geht es mit folgender (ungetesteter) Funktion. Anstatt die Leerzeichen, Tabs,... wirklich zu entfernen, wird nur geprüft, ob ein String nur "Weißraum" enthält.
Delphi-Quellcode:
function IsWhiteSpace(const S: string): Boolean;
var I: Integer; begin I := Length(S); while (I > 0) and (S[I] <= ' ') do Dec(I); Result := (I = 0); end; |
Alle Zeitangaben in WEZ +1. Es ist jetzt 20:29 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz