Simplify checking of container (List/HashTable, strings) sizes

- can use 'XX.empty()' instead of 'XX.size() == 0', 'XX.size() < 1' or
  'XX.size() <= 0' or for simpler coding.
  It also has the same number of characters as '!XX.size()' and /might/ be
  more readable

- many size checking had 'XX.size() > 0', 'XX.size() != 0', or 'XX.size() >= 1'
  when a simple 'XX.size()' suffices
This commit is contained in:
Mark Olesen
2009-01-10 20:28:06 +01:00
parent 16aaf5b54e
commit 95dcb6ded7
211 changed files with 713 additions and 832 deletions

View File

@ -284,7 +284,7 @@ Foam::fileName Foam::findEtcFile(const fileName& name, bool mandatory)
bool Foam::mkDir(const fileName& pathName, mode_t mode)
{
// empty names are meaningless
if (!pathName.size())
if (pathName.empty())
{
return false;
}
@ -567,10 +567,10 @@ Foam::fileNameList Foam::readDir
{
fileName fName(list->d_name);
// ignore files begining with ., i.e. ., .. and .??*
if (fName.size() > 0 && fName[size_t(0)] != '.')
// ignore files begining with ., i.e. '.', '..' and '.*'
if (fName.size() && fName[0] != '.')
{
word fileNameExt = fName.ext();
word fExt = fName.ext();
if
(
@ -578,11 +578,11 @@ Foam::fileNameList Foam::readDir
||
(
type == fileName::FILE
&& fName[fName.size()-1] != '~'
&& fileNameExt != "bak"
&& fileNameExt != "BAK"
&& fileNameExt != "old"
&& fileNameExt != "save"
&& fName[fName.size()-1] != '~'
&& fExt != "bak"
&& fExt != "BAK"
&& fExt != "old"
&& fExt != "save"
)
)
{
@ -593,7 +593,7 @@ Foam::fileNameList Foam::readDir
dirEntries.setSize(dirEntries.size() + maxNnames);
}
if (filtergz && fileNameExt == "gz")
if (filtergz && fExt == "gz")
{
dirEntries[nEntries++] = fName.lessExt();
}
@ -616,17 +616,17 @@ Foam::fileNameList Foam::readDir
}
// Copy, recursively if necessary, the source top the destination
// Copy, recursively if necessary, the source to the destination
bool Foam::cp(const fileName& src, const fileName& dest)
{
fileName destFile(dest);
// Make sure source exists.
if (!exists(src))
{
return false;
}
fileName destFile(dest);
// Check type of source file.
if (src.type() == fileName::FILE)
{
@ -676,7 +676,7 @@ bool Foam::cp(const fileName& src, const fileName& dest)
destFile = destFile/src.component(src.components().size() -1);
}
// Make sure the destination directory extists.
// Make sure the destination directory exists.
if (!dir(destFile) && !mkDir(destFile))
{
return false;