git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@11496
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
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
+ // 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);
while ( !matches )
{
de = readdir(m_dir);
{
if ( !(m_flags & wxDIR_DOTDOT) )
continue;
{
if ( !(m_flags & wxDIR_DOTDOT) )
continue;
+
+ // we found a valid match
+ break;
- 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;
}
{
// 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
{
// it's a dir, and we don't want it
continue;
}
// finally, check the name
+ if ( m_filespec.empty() )
{
matches = m_flags & wxDIR_HIDDEN ? TRUE : de->d_name[0] != '.';
}
{
matches = m_flags & wxDIR_HIDDEN ? TRUE : de->d_name[0] != '.';
}