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

@ -238,9 +238,9 @@ void Foam::fileName::operator=(const char* str)
Foam::fileName Foam::operator/(const string& a, const string& b)
{
if (a.size() > 0) // First string non-null
if (a.size()) // First string non-null
{
if (b.size() > 0) // Second string non-null
if (b.size()) // Second string non-null
{
return fileName(a + '/' + b);
}
@ -251,7 +251,7 @@ Foam::fileName Foam::operator/(const string& a, const string& b)
}
else // First string null
{
if (b.size() > 0) // Second string non-null
if (b.size()) // Second string non-null
{
return b;
}

View File

@ -162,17 +162,17 @@ inline void Foam::word::operator=(const char* q)
inline Foam::word Foam::operator&(const word& a, const word& b)
{
if (!b.size())
{
return a;
}
else
if (b.size())
{
string ub = b;
ub.string::operator[](0) = char(toupper(ub.string::operator[](0)));
return a + ub;
}
else
{
return a;
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -61,7 +61,7 @@ Foam::Istream& Foam::operator>>(Istream& is, word& w)
string::stripInvalid<word>(w);
// flag empty strings and bad chars as an error
if (!w.size() || w.size() != t.stringToken().size())
if (w.empty() || w.size() != t.stringToken().size())
{
is.setBad();
FatalIOErrorIn("operator>>(Istream&, word&)", is)