STYLE: use string substr instead of string::operator()

- makes the purpose clearer.
  In some places, string::resize() is even simpler.

- use C++11 string::back() in preference to str[str.size()-1]
This commit is contained in:
Mark Olesen
2017-07-21 12:30:42 +02:00
parent 72f242405a
commit 8df433860f
26 changed files with 148 additions and 174 deletions

View File

@ -74,7 +74,7 @@ bool Foam::fileFormats::NASedgeFormat::read
// Check if character 72 is continuation
if (line.size() > 72 && line[72] == '+')
{
line = line.substr(0, 72);
line.resize(72);
while (true)
{
@ -87,7 +87,7 @@ bool Foam::fileFormats::NASedgeFormat::read
}
else
{
line += buf.substr(8, buf.size()-8);
line += buf.substr(8);
break;
}
}

View File

@ -117,9 +117,9 @@ bool Foam::fileFormats::OBJedgeFormat::read(const fileName& filename)
string line = this->getLineNoComment(is);
// handle continuations
if (line[line.size()-1] == '\\')
if (line.back() == '\\')
{
line.substr(0, line.size()-1);
line.resize(line.size()-1);
line += this->getLineNoComment(is);
}