diff --git a/include/wx/fs_mem.h b/include/wx/fs_mem.h index f62d21c2fd..08f879b4d1 100644 --- a/include/wx/fs_mem.h +++ b/include/wx/fs_mem.h @@ -64,11 +64,10 @@ protected: // the file name currently being searched for, i.e. the argument of the // last FindFirst() call or empty string if FindFirst() hasn't been called - // yet or FindNext() didn't find anything + // yet wxString m_findArgument; - // iterator into m_Hash used by FindFirst/Next(), possibly m_Hash.end() or - // even invalid (can only be used when m_findArgument is not empty) + // iterator into m_Hash used by FindFirst/Next(), possibly m_Hash.end() wxMemoryFSHash::const_iterator m_findIter; }; diff --git a/src/common/fs_mem.cpp b/src/common/fs_mem.cpp index 281cdbbc88..dd74323c36 100644 --- a/src/common/fs_mem.cpp +++ b/src/common/fs_mem.cpp @@ -147,22 +147,16 @@ wxString wxMemoryFSHandlerBase::FindFirst(const wxString& url, int flags) wxString wxMemoryFSHandlerBase::FindNext() { - // m_findArgument is used to indicate that search is in progress, we reset - // it to empty string after iterating over all elements - while ( !m_findArgument.empty() ) + while ( m_findIter != m_Hash.end() ) { - // test for the match before (possibly) clearing m_findArgument below - const bool found = m_findIter->first.Matches(m_findArgument); + const wxString& path = m_findIter->first; // advance m_findIter first as we need to do it anyhow, whether it // matches or not - const wxMemoryFSHash::const_iterator current = m_findIter; + ++m_findIter; - if ( ++m_findIter == m_Hash.end() ) - m_findArgument.clear(); - - if ( found ) - return "memory:" + current->first; + if ( path.Matches(m_findArgument) ) + return "memory:" + path; } return wxString();