mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
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:
@ -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;
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -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)
|
||||
|
||||
Reference in New Issue
Block a user