1
0
mirror of git://projects.qi-hardware.com/gmenu2x.git synced 2024-09-30 00:55:27 +03:00

Convert file name to C++ string as late as possible

This avoids copying the string if the file is rejected because its
category (directory or regular file) is disabled.
This commit is contained in:
Maarten ter Huurne 2014-08-14 05:30:31 +02:00
parent b6f6bb387c
commit 56beec0895

View File

@ -93,7 +93,6 @@ void FileLister::browse(const string& path, bool clean)
}
}
string file = dptr->d_name;
bool isDir;
#ifdef DT_DIR
if (dptr->d_type != DT_UNKNOWN) {
@ -101,7 +100,7 @@ void FileLister::browse(const string& path, bool clean)
} else
#endif
{
string filepath = slashedPath + file;
string filepath = slashedPath + dptr->d_name;
struct stat st;
int statRet = stat(filepath.c_str(), &st);
if (statRet == -1) {
@ -115,16 +114,17 @@ void FileLister::browse(const string& path, bool clean)
if (!showDirectories)
continue;
directorySet.insert(file);
directorySet.insert(string(dptr->d_name));
} else {
if (!showFiles)
continue;
if (filter.empty()) {
fileSet.insert(file);
fileSet.insert(string(dptr->d_name));
continue;
}
string file = dptr->d_name;
for (vector<string>::iterator it = filter.begin(); it != filter.end(); ++it) {
if (file.find('.') == string::npos) {
if (!it->empty())