Simplify some statements

This commit is contained in:
Ayaz Salikhov 2017-06-01 02:02:12 +03:00
parent 3cd2f2d092
commit 132c0af22a
3 changed files with 6 additions and 15 deletions

View File

@ -231,19 +231,13 @@ void FileLister::addFiles(std::map<std::string, std::size_t> &files, const std::
bool FileLister::isDirectory(const std::string &path)
{
struct stat file_stat;
if (stat(path.c_str(), &file_stat) != -1)
return ((file_stat.st_mode & S_IFMT) == S_IFDIR);
return false;
return (stat(path.c_str(), &file_stat) != -1 && (file_stat.st_mode & S_IFMT) == S_IFDIR);
}
bool FileLister::fileExists(const std::string &path)
{
struct stat file_stat;
if (stat(path.c_str(), &file_stat) != -1)
return ((file_stat.st_mode & S_IFMT) == S_IFREG);
return false;
return (stat(path.c_str(), &file_stat) != -1 && (file_stat.st_mode & S_IFMT) == S_IFREG);
}
#endif

View File

@ -1064,7 +1064,7 @@ public:
/** is variable unused? */
bool unused() const {
return (_read == false && _write == false);
return (!_read && !_write);
}
const Token *_name;

View File

@ -251,7 +251,7 @@ bool Path::isC(const std::string &path)
bool Path::isCPP(const std::string &path)
{
const std::string extension = getFilenameExtensionInLowerCase(path);
if (extension == ".cpp" ||
return extension == ".cpp" ||
extension == ".cxx" ||
extension == ".cc" ||
extension == ".c++" ||
@ -259,12 +259,9 @@ bool Path::isCPP(const std::string &path)
extension == ".hxx" ||
extension == ".hh" ||
extension == ".tpp" ||
extension == ".txx") {
return true;
}
extension == ".txx" ||
getFilenameExtension(path) == ".C";
// In unix, ".C" is considered C++ file
return (getFilenameExtension(path) == ".C");
}
bool Path::acceptFile(const std::string &path, const std::set<std::string> &extra)