Skip to content

Commit 132c0af

Browse files
committed
Simplify some statements
1 parent 3cd2f2d commit 132c0af

3 files changed

Lines changed: 6 additions & 15 deletions

File tree

cli/filelister.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -231,19 +231,13 @@ void FileLister::addFiles(std::map<std::string, std::size_t> &files, const std::
231231
bool FileLister::isDirectory(const std::string &path)
232232
{
233233
struct stat file_stat;
234-
if (stat(path.c_str(), &file_stat) != -1)
235-
return ((file_stat.st_mode & S_IFMT) == S_IFDIR);
236-
237-
return false;
234+
return (stat(path.c_str(), &file_stat) != -1 && (file_stat.st_mode & S_IFMT) == S_IFDIR);
238235
}
239236

240237
bool FileLister::fileExists(const std::string &path)
241238
{
242239
struct stat file_stat;
243-
if (stat(path.c_str(), &file_stat) != -1)
244-
return ((file_stat.st_mode & S_IFMT) == S_IFREG);
245-
246-
return false;
240+
return (stat(path.c_str(), &file_stat) != -1 && (file_stat.st_mode & S_IFMT) == S_IFREG);
247241
}
248242

249243
#endif

gui/test/data/benchmark/simple.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1064,7 +1064,7 @@ class Variables {
10641064

10651065
/** is variable unused? */
10661066
bool unused() const {
1067-
return (_read == false && _write == false);
1067+
return (!_read && !_write);
10681068
}
10691069

10701070
const Token *_name;

lib/path.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -251,20 +251,17 @@ bool Path::isC(const std::string &path)
251251
bool Path::isCPP(const std::string &path)
252252
{
253253
const std::string extension = getFilenameExtensionInLowerCase(path);
254-
if (extension == ".cpp" ||
254+
return extension == ".cpp" ||
255255
extension == ".cxx" ||
256256
extension == ".cc" ||
257257
extension == ".c++" ||
258258
extension == ".hpp" ||
259259
extension == ".hxx" ||
260260
extension == ".hh" ||
261261
extension == ".tpp" ||
262-
extension == ".txx") {
263-
return true;
264-
}
265-
262+
extension == ".txx" ||
263+
getFilenameExtension(path) == ".C";
266264
// In unix, ".C" is considered C++ file
267-
return (getFilenameExtension(path) == ".C");
268265
}
269266

270267
bool Path::acceptFile(const std::string &path, const std::set<std::string> &extra)

0 commit comments

Comments
 (0)