Programm unglaublich langsam
-
Hallo,
So wird er nicht langsamer, ist aber immer noch nicht so schnell wie der andere. Man könnte da immer noch was optimieren...
// Datei in StringList laden AnsiString NeuerText = ""; AnsiString Zeile = ""; TStringList *dat = new TStringList(); dat->LoadFromFile("test.txt"); for (int i = 0; i < dat->Count; i++) NeuerText += dat->Strings[i]; dat->Clear(); for (int i = 1; i <= NeuerText.Length(); i++) { if (NeuerText[i] == '#') { dat->Add(Zeile); Zeile = ""; } // if (NeuerText[i] == '#') else Zeile += NeuerText[i]; } // for (int i = 1; i <= NeuerText.Length(); i++) //Anzahl der Rows berechnen (Anzahl Einträge in Liste / 2 Spalten) StringGrid1->RowCount = dat->Count / 2; //Daten ins Grid schreiben for(int i = 0; i < dat->Count - 1; i += 2) { StringGrid1->Cells[0][i/2]=dat->Strings [i]; StringGrid1->Cells[1][i/2]=dat->Strings [i+1]; } // for(int i = 0; i < dat->Count - 1; i += 2) dat->SaveToFile(ExtractFilePath(Application->ExeName) + "neu.txt"); if (dat != NULL) { dat->Clear(); delete dat; dat = NULL; } // if (dat != NULL)Nash
-
danke, jetzt ist der code schell genug.