From 132c0af22af0977a0b5e3fc260b27a4173a2667d Mon Sep 17 00:00:00 2001 From: Ayaz Salikhov Date: Thu, 1 Jun 2017 02:02:12 +0300 Subject: [PATCH] Simplify some statements --- cli/filelister.cpp | 10 ++-------- gui/test/data/benchmark/simple.cpp | 2 +- lib/path.cpp | 9 +++------ 3 files changed, 6 insertions(+), 15 deletions(-) diff --git a/cli/filelister.cpp b/cli/filelister.cpp index ad958ab87..c68645950 100644 --- a/cli/filelister.cpp +++ b/cli/filelister.cpp @@ -231,19 +231,13 @@ void FileLister::addFiles(std::map &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 diff --git a/gui/test/data/benchmark/simple.cpp b/gui/test/data/benchmark/simple.cpp index b0370de7f..80bbb346a 100644 --- a/gui/test/data/benchmark/simple.cpp +++ b/gui/test/data/benchmark/simple.cpp @@ -1064,7 +1064,7 @@ public: /** is variable unused? */ bool unused() const { - return (_read == false && _write == false); + return (!_read && !_write); } const Token *_name; diff --git a/lib/path.cpp b/lib/path.cpp index 57aaf8ba2..f498cd467 100644 --- a/lib/path.cpp +++ b/lib/path.cpp @@ -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 &extra)