Readability fix for MS isRelative, isAbsolute.

The layout and phrasing of these two QFileSystemEntry methods was such
as to obscure what they actually test.  (Overlong lines, extraneous
parentheses, spurious conditions and poor line-breaking.)  Rewrote to
make both clearer; and, in particular, to make it obvious that they
are *not* mutually complementary.  Behavior is not changed.

Change-Id: If748e48d41fe3a76bab3a1f840c7b7ca62442f8f
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
This commit is contained in:
Edward Welbourne 2016-02-04 09:41:22 +01:00
parent 2ddd11dde2
commit 22c262d2d7

View File

@ -260,17 +260,21 @@ QString QFileSystemEntry::completeSuffix() const
bool QFileSystemEntry::isRelative() const
{
resolveFilePath();
return (m_filePath.isEmpty() || (!m_filePath.isEmpty() && (m_filePath.at(0).unicode() != '/')
&& (!(m_filePath.length() >= 2 && m_filePath.at(1).unicode() == ':'))));
return (m_filePath.isEmpty()
|| (m_filePath.at(0).unicode() != '/'
&& !(m_filePath.length() >= 2 && m_filePath.at(1).unicode() == ':')));
}
bool QFileSystemEntry::isAbsolute() const
{
resolveFilePath();
return (!m_filePath.isEmpty() && ((m_filePath.length() >= 3
&& (m_filePath.at(0).isLetter() && m_filePath.at(1).unicode() == ':' && m_filePath.at(2).unicode() == '/'))
|| (m_filePath.length() >= 2 && (m_filePath.at(0) == QLatin1Char('/') && m_filePath.at(1) == QLatin1Char('/')))
));
return ((m_filePath.length() >= 3
&& m_filePath.at(0).isLetter()
&& m_filePath.at(1).unicode() == ':'
&& m_filePath.at(2).unicode() == '/')
|| (m_filePath.length() >= 2
&& m_filePath.at(0) == QLatin1Char('/')
&& m_filePath.at(1) == QLatin1Char('/')));
}
#else
bool QFileSystemEntry::isRelative() const