Commit d1162156 authored by Hahn, Steven's avatar Hahn, Steven
Browse files

Changes suggested by readability-simplify-boolean-expr.

parent cc032dd2
......@@ -1419,7 +1419,7 @@ bool Algorithm::isWorkspaceProperty(const Kernel::Property *const prop) const {
}
const IWorkspaceProperty *const wsProp =
dynamic_cast<const IWorkspaceProperty *>(prop);
return (wsProp ? true : false);
return (wsProp != nullptr);
}
//=============================================================================================
......
......@@ -212,10 +212,7 @@ std::string BoxController::getFilename() const {
/** the function left for compartibility with the previous bc python interface.
@return true if the workspace is file based and false otherwise */
bool BoxController::useWriteBuffer() const {
if (m_fileIO)
return true;
else
return false;
return static_cast<bool>(m_fileIO);
}
//------------------------------------------------------------------------------------------------------
......
......@@ -309,11 +309,7 @@ void Expression::tokenize() {
}
if (c == '"') {
if (!inString) {
inString = true;
} else {
inString = false;
}
inString = !inString;
}
} // for i
......@@ -401,10 +397,7 @@ void Expression::setFunct(const std::string &name) {
bool inQuotes = false;
for (std::string::const_iterator c = name.begin(); c != name.end(); ++c) {
if (*c == '"') {
if (inQuotes)
inQuotes = false;
else
inQuotes = true;
inQuotes = !inQuotes;
continue;
}
......
......@@ -37,9 +37,7 @@ Mantid::Kernel::Logger g_log("FileFinder");
* @returns true if extension contains a "*", else false.
*/
bool containsWildCard(const std::string &ext) {
if (std::string::npos != ext.find("*"))
return true;
return false;
return std::string::npos != ext.find("*");
}
}
......
......@@ -160,10 +160,7 @@ bool FileLoaderRegistryImpl::canLoad(const std::string &algorithmName,
loader = searchForLoader<FileDescriptor, IFileLoader<FileDescriptor>>(
filename, names, m_log);
}
if (loader)
return true;
else
return false;
return static_cast<bool>(loader);
}
//----------------------------------------------------------------------------------------------
......
......@@ -220,10 +220,7 @@ bool IPowderDiffPeakFunction::hasProfileParameter(std::string paramname) {
return false;
std::string candname = *niter;
if (candname.compare(paramname))
return false;
return true;
return !static_cast<bool>(candname.compare(paramname));
}
//------------------------- External Functions
......
......@@ -952,7 +952,7 @@ bool &MatrixWorkspace::isDistribution(bool newValue) {
* @return whether the workspace contains histogram data
*/
bool MatrixWorkspace::isHistogramData() const {
return (readX(0).size() == blocksize() ? false : true);
return (readX(0).size() != blocksize());
}
/**
......@@ -1097,7 +1097,7 @@ bool MatrixWorkspace::hasMaskedBins(const size_t &workspaceIndex) const {
// against throwing here).
if (workspaceIndex >= this->getNumberHistograms())
return false;
return (m_masks.find(workspaceIndex) == m_masks.end()) ? false : true;
return m_masks.find(workspaceIndex) != m_masks.end();
}
/** Returns the list of masked bins for a spectrum.
......
......@@ -29,9 +29,7 @@ Mantid::Kernel::Logger g_log("MultipleFileProperty");
* a "*" wild card in the file extension string passed to it.
*/
bool doesNotContainWildCard(const std::string &ext) {
if (std::string::npos != ext.find("*"))
return false;
return true;
return std::string::npos == ext.find("*");
}
} // anonymous namespace
......@@ -345,10 +343,7 @@ MultipleFileProperty::setValueAsMultipleFiles(const std::string &propValue) {
// Check for an extension.
Poco::Path path(*unresolvedFileName);
if (path.getExtension().empty())
useDefaultExt = true;
else
useDefaultExt = false;
useDefaultExt = path.getExtension().empty();
} catch (Poco::Exception &) {
// Just shove the problematic filename straight into FileProperty and
// see
......
......@@ -86,10 +86,7 @@ bool RefAxis::operator==(const Axis &axis2) const {
return false;
}
const RefAxis *ra2 = dynamic_cast<const RefAxis *>(&axis2);
if (!ra2) {
return false;
}
return true;
return ra2 != nullptr;
}
/** Check if two numeric axis are equivalent to a given tolerance
......
......@@ -193,11 +193,7 @@ void Sample::setCrystalStructure(
bool Sample::hasCrystalStructure() const {
// Conversion to bool seems to be a problem in VS2012, so this is a bit more
// verbose than it should be.
if (m_crystalStructure) {
return true;
}
return false;
return static_cast<bool>(m_crystalStructure);
}
/// Destroys the internally stored CrystalStructure-object.
......
......@@ -356,7 +356,7 @@ bool ChangeTimeZero::checkForDateTime(const std::string &val) const {
* @returns true if the offset has been set
*/
bool ChangeTimeZero::isRelativeTimeShift(double offset) const {
return offset != m_defaultTimeShift ? true : false;
return offset != m_defaultTimeShift;
}
/**
......@@ -365,9 +365,7 @@ bool ChangeTimeZero::isRelativeTimeShift(double offset) const {
* @returns true if the offset has been set
*/
bool ChangeTimeZero::isAbsoluteTimeShift(const std::string &offset) const {
return (offset != m_defaultAbsoluteTimeShift && checkForDateTime(offset))
? true
: false;
return offset != m_defaultAbsoluteTimeShift && checkForDateTime(offset);
}
} // namespace Mantid
......
......@@ -75,7 +75,7 @@ void CorrectToFile::exec() {
const MantidVec &Ecor = rkhInput->readE(0);
const bool histogramData = outputWS->isHistogramData();
const bool divide = (operation == "Divide") ? true : false;
const bool divide = operation == "Divide";
double Yfactor, correctError;
const int64_t nOutSpec =
......
......@@ -42,7 +42,7 @@ void ExponentialCorrection::retrieveProperties() {
m_c0 = getProperty("C0");
m_c1 = getProperty("C1");
std::string op = getProperty("Operation");
m_divide = (op == "Divide") ? true : false;
m_divide = op == "Divide";
}
void ExponentialCorrection::performUnaryOperation(const double XIn,
......
......@@ -697,10 +697,7 @@ bool GeneratePeaks::hasParameter(API::IFunction_sptr function,
std::vector<std::string> parnames = function->getParameterNames();
std::vector<std::string>::iterator piter;
piter = std::find(parnames.begin(), parnames.end(), paramname);
if (piter != parnames.end())
return true;
return false;
return piter != parnames.end();
}
//----------------------------------------------------------------------------------------------
......
......@@ -167,7 +167,7 @@ void MaskDetectorsIf::createNewCalFile(const std::string &oldfile,
bool selection;
if (it == umap.end())
selection = (sel == 0) ? false : true;
selection = sel != 0;
else
selection = (*it).second;
......
......@@ -64,10 +64,7 @@ bool MonIDPropChanger::isConditionChanged(const IPropertyManager *algo) const {
// std::cout << "MonIDPropChanger::isConditionChanged() called ";
// std::cout << monitors_changed << std::endl;
if (!monitors_changed)
return false;
return true;
return monitors_changed;
}
// function which modifies the allowed values for the list of monitors.
void MonIDPropChanger::applyChanges(const IPropertyManager *algo,
......
......@@ -39,7 +39,7 @@ void OneMinusExponentialCor::retrieveProperties() {
m_c = getProperty("C");
m_c1 = getProperty("C1");
std::string op = getProperty("Operation");
m_divide = (op == "Divide") ? true : false;
m_divide = op == "Divide";
}
void OneMinusExponentialCor::performUnaryOperation(const double XIn,
......
......@@ -156,10 +156,7 @@ bool closeEnough(const double left, const double right) {
// same within 5%
const double relativeDiff = diff * 2 / (left + right);
if (relativeDiff < .05)
return true;
return false;
return relativeDiff < .05;
}
/// Fill in the property manager from the correct line in the table
......
......@@ -43,7 +43,7 @@ void PolynomialCorrection::retrieveProperties() {
m_coeffs = getProperty("Coefficients");
m_polySize = m_coeffs.size();
std::string operation = getProperty("Operation");
m_isOperationMultiply = operation == "Multiply" ? true : false;
m_isOperationMultiply = operation == "Multiply";
}
void PolynomialCorrection::performUnaryOperation(const double XIn,
......
......@@ -120,7 +120,7 @@ void Q1D2::exec() {
// iterations of the loop below
// Flag to decide if Q Resolution is to be used
auto useQResolution = qResolution ? true : false;
auto useQResolution = static_cast<bool>(qResolution);
// this will become the output workspace from this algorithm
MatrixWorkspace_sptr outputWS =
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment