From: Vadim Zeitlin Date: Mon, 27 Aug 2001 18:27:42 +0000 (+0000) Subject: attempt to optimize wxDirData::Read() - made absolutely no difference X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/b0d3640289e13d5e13b4b80727a006803d273ab7 attempt to optimize wxDirData::Read() - made absolutely no difference git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@11496 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/unix/dir.cpp b/src/unix/dir.cpp index 13b8d2a68a..8364eddf5a 100644 --- a/src/unix/dir.cpp +++ b/src/unix/dir.cpp @@ -117,9 +117,14 @@ wxDirData::~wxDirData() bool wxDirData::Read(wxString *filename) { - dirent *de = (dirent *)NULL; // just to silent compiler warnings + dirent *de = (dirent *)NULL; // just to silence compiler warnings bool matches = FALSE; + // speed up string concatenation in the loop a bit + wxString path = m_dirname; + path += _T('/'); + path.reserve(path.length() + 255); + while ( !matches ) { de = readdir(m_dir); @@ -133,24 +138,25 @@ bool wxDirData::Read(wxString *filename) { if ( !(m_flags & wxDIR_DOTDOT) ) continue; + + // we found a valid match + break; } // check the type now - if ( !(m_flags & wxDIR_FILES) && - !wxDir::Exists(m_dirname + _T('/') + de->d_name) ) + if ( !(m_flags & wxDIR_FILES) && !wxDir::Exists(path + de->d_name) ) { // it's a file, but we don't want them continue; } - else if ( !(m_flags & wxDIR_DIRS) && - wxDir::Exists(m_dirname + _T('/') + de->d_name) ) + else if ( !(m_flags & wxDIR_DIRS) && wxDir::Exists(path + de->d_name) ) { // it's a dir, and we don't want it continue; } // finally, check the name - if ( !m_filespec ) + if ( m_filespec.empty() ) { matches = m_flags & wxDIR_HIDDEN ? TRUE : de->d_name[0] != '.'; }