Iterate over wxTextFile without using indices

Using iterator methods is less error-prone (there is no danger of using an
invalid index) and slightly shorter and more clear too.
This commit is contained in:
Vadim Zeitlin
2017-03-09 18:06:33 +01:00
parent 058f8c3c0f
commit 3ad54f2852

View File

@@ -307,10 +307,10 @@ wxString wxStandardPaths::GetUserDir(Dir userDir) const
wxTextFile textFile; wxTextFile textFile;
if ( textFile.Open(dirsFile.GetFullPath()) ) if ( textFile.Open(dirsFile.GetFullPath()) )
{ {
size_t i; for ( wxString line = textFile.GetFirstLine();
for (i = 0; i < textFile.GetLineCount(); i++) !textFile.Eof();
line = textFile.GetNextLine() )
{ {
wxString line(textFile[i]);
int pos = line.Find(userDirId); int pos = line.Find(userDirId);
if (pos != wxNOT_FOUND) if (pos != wxNOT_FOUND)
{ {