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:
@@ -117,9 +117,14 @@ wxDirData::~wxDirData()
|
|||||||
|
|
||||||
bool wxDirData::Read(wxString *filename)
|
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;
|
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 )
|
while ( !matches )
|
||||||
{
|
{
|
||||||
de = readdir(m_dir);
|
de = readdir(m_dir);
|
||||||
@@ -133,24 +138,25 @@ bool wxDirData::Read(wxString *filename)
|
|||||||
{
|
{
|
||||||
if ( !(m_flags & wxDIR_DOTDOT) )
|
if ( !(m_flags & wxDIR_DOTDOT) )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
// we found a valid match
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// check the type now
|
// check the type now
|
||||||
if ( !(m_flags & wxDIR_FILES) &&
|
if ( !(m_flags & wxDIR_FILES) && !wxDir::Exists(path + de->d_name) )
|
||||||
!wxDir::Exists(m_dirname + _T('/') + de->d_name) )
|
|
||||||
{
|
{
|
||||||
// it's a file, but we don't want them
|
// it's a file, but we don't want them
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if ( !(m_flags & wxDIR_DIRS) &&
|
else if ( !(m_flags & wxDIR_DIRS) && wxDir::Exists(path + de->d_name) )
|
||||||
wxDir::Exists(m_dirname + _T('/') + de->d_name) )
|
|
||||||
{
|
{
|
||||||
// it's a dir, and we don't want it
|
// it's a dir, and we don't want it
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// finally, check the name
|
// finally, check the name
|
||||||
if ( !m_filespec )
|
if ( m_filespec.empty() )
|
||||||
{
|
{
|
||||||
matches = m_flags & wxDIR_HIDDEN ? TRUE : de->d_name[0] != '.';
|
matches = m_flags & wxDIR_HIDDEN ? TRUE : de->d_name[0] != '.';
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user