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
This commit is contained in:
Vadim Zeitlin
2001-08-27 18:27:42 +00:00
parent 2a4dbd8197
commit b0d3640289

View File

@@ -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] != '.';
}