Commit 8acad618 authored by Hahn, Steven's avatar Hahn, Steven
Browse files

Apply changes from clang-tidy readability-container-size-empty.

parent 9f49657e
...@@ -75,7 +75,7 @@ public: ...@@ -75,7 +75,7 @@ public:
/// string but recreates it. /// string but recreates it.
std::string str() const; std::string str() const;
/// Returns true if the expression is a function (i.e. has arguments) /// Returns true if the expression is a function (i.e. has arguments)
bool isFunct() const { return m_terms.size() > 0; } bool isFunct() const { return !m_terms.empty(); }
/// Returns the name of the expression which is a function or variable name. /// Returns the name of the expression which is a function or variable name.
std::string name() const { return m_funct; } std::string name() const { return m_funct; }
/// Returns the the expression's binary operator on its left. Can be an empty /// Returns the the expression's binary operator on its left. Can be an empty
......
...@@ -383,7 +383,7 @@ size_t CompositeFunction::addFunction(IFunction_sptr f) { ...@@ -383,7 +383,7 @@ size_t CompositeFunction::addFunction(IFunction_sptr f) {
m_IFunction.insert(m_IFunction.end(), f->nParams(), m_functions.size()); m_IFunction.insert(m_IFunction.end(), f->nParams(), m_functions.size());
m_functions.push_back(f); m_functions.push_back(f);
//?f->init(); //?f->init();
if (m_paramOffsets.size() == 0) { if (m_paramOffsets.empty()) {
m_paramOffsets.push_back(0); m_paramOffsets.push_back(0);
m_nParams = f->nParams(); m_nParams = f->nParams();
} else { } else {
......
...@@ -134,7 +134,7 @@ void Expression::parse(const std::string &str) { ...@@ -134,7 +134,7 @@ void Expression::parse(const std::string &str) {
tokenize(); tokenize();
if (m_tokens.size() == 0) { if (m_tokens.empty()) {
setFunct(m_expr); setFunct(m_expr);
return; return;
} }
...@@ -310,7 +310,7 @@ void Expression::tokenize() { ...@@ -310,7 +310,7 @@ void Expression::tokenize() {
} // for i } // for i
if (tokens.size()) { if (!tokens.empty()) {
// remove operators of higher prec // remove operators of higher prec
m_tokens.push_back(Token(tokens[0])); m_tokens.push_back(Token(tokens[0]));
for (size_t i = 0; i < tokens.size(); i++) { for (size_t i = 0; i < tokens.size(); i++) {
...@@ -328,7 +328,7 @@ void Expression::tokenize() { ...@@ -328,7 +328,7 @@ void Expression::tokenize() {
} }
std::string Expression::GetToken(size_t i) { std::string Expression::GetToken(size_t i) {
if (m_tokens.size() == 0) if (m_tokens.empty())
return m_expr; return m_expr;
if (i < m_tokens.size()) { if (i < m_tokens.size()) {
...@@ -345,7 +345,7 @@ std::string Expression::GetToken(size_t i) { ...@@ -345,7 +345,7 @@ std::string Expression::GetToken(size_t i) {
} }
std::string Expression::GetOp(size_t i) { std::string Expression::GetOp(size_t i) {
if (m_tokens.size() == 0 || i >= m_tokens.size()) if (m_tokens.empty() || i >= m_tokens.size())
return ""; return "";
Token &tok = m_tokens[i]; Token &tok = m_tokens[i];
...@@ -354,7 +354,7 @@ std::string Expression::GetOp(size_t i) { ...@@ -354,7 +354,7 @@ std::string Expression::GetOp(size_t i) {
void Expression::logPrint(const std::string &pads) const { void Expression::logPrint(const std::string &pads) const {
std::string myPads = pads + " "; std::string myPads = pads + " ";
if (m_terms.size()) { if (!m_terms.empty()) {
std::cerr << myPads << m_op << '[' << m_funct << ']' << "(" << '\n'; std::cerr << myPads << m_op << '[' << m_funct << ']' << "(" << '\n';
for (const auto &term : m_terms) for (const auto &term : m_terms)
term.logPrint(myPads); term.logPrint(myPads);
...@@ -442,7 +442,7 @@ std::string Expression::str() const { ...@@ -442,7 +442,7 @@ std::string Expression::str() const {
brackets = true; brackets = true;
} }
if (m_terms.size()) { if (!m_terms.empty()) {
if (brackets) if (brackets)
res << '('; res << '(';
for (const auto &term : m_terms) { for (const auto &term : m_terms) {
......
...@@ -760,7 +760,7 @@ FileFinderImpl::getPath(const std::vector<IArchiveSearch_sptr> &archs, ...@@ -760,7 +760,7 @@ FileFinderImpl::getPath(const std::vector<IArchiveSearch_sptr> &archs,
} }
// Search the archive // Search the archive
if (archs.size() != 0) { if (!archs.empty()) {
g_log.debug() << "Search the archives\n"; g_log.debug() << "Search the archives\n";
std::string path = getArchivePath(archs, filenames, exts); std::string path = getArchivePath(archs, filenames, exts);
try { try {
......
...@@ -78,7 +78,7 @@ FileProperty::FileProperty(const std::string &name, ...@@ -78,7 +78,7 @@ FileProperty::FileProperty(const std::string &name,
unsigned int direction) unsigned int direction)
: PropertyWithValue<std::string>(name, defaultValue, : PropertyWithValue<std::string>(name, defaultValue,
createValidator(action, exts), direction), createValidator(action, exts), direction),
m_action(action), m_defaultExt((exts.size() > 0) ? exts.front() : ""), m_action(action), m_defaultExt((!exts.empty()) ? exts.front() : ""),
m_runFileProp(isLoadProperty() && extsMatchRunFiles()), m_runFileProp(isLoadProperty() && extsMatchRunFiles()),
m_oldLoadPropValue(""), m_oldLoadFoundFile("") {} m_oldLoadPropValue(""), m_oldLoadFoundFile("") {}
......
...@@ -16,7 +16,7 @@ Kernel::Logger g_log("GridDomain"); ...@@ -16,7 +16,7 @@ Kernel::Logger g_log("GridDomain");
/// number of points in the grid /// number of points in the grid
size_t GridDomain::size() const { size_t GridDomain::size() const {
if (!m_grids.size()) if (m_grids.empty())
return 0; return 0;
else else
return std::accumulate( return std::accumulate(
......
...@@ -59,7 +59,7 @@ void HistoryView::unroll(std::vector<HistoryItem>::iterator &it) { ...@@ -59,7 +59,7 @@ void HistoryView::unroll(std::vector<HistoryItem>::iterator &it) {
const auto history = it->getAlgorithmHistory(); const auto history = it->getAlgorithmHistory();
const auto childHistories = history->getChildHistories(); const auto childHistories = history->getChildHistories();
if (!it->isUnrolled() && childHistories.size() > 0) { if (!it->isUnrolled() && !childHistories.empty()) {
// mark this record as being ignored by the script builder // mark this record as being ignored by the script builder
it->unrolled(true); it->unrolled(true);
......
...@@ -328,7 +328,7 @@ protected: ...@@ -328,7 +328,7 @@ protected:
/// Apply if vector /// Apply if vector
std::string apply(const std::vector<double> &v) const override { std::string apply(const std::vector<double> &v) const override {
std::string res = "("; std::string res = "(";
if (v.size() > 0) { if (!v.empty()) {
for (size_t i = 0; i < v.size() - 1; ++i) { for (size_t i = 0; i < v.size() - 1; ++i) {
res += boost::lexical_cast<std::string>(v[i]) + ","; res += boost::lexical_cast<std::string>(v[i]) + ",";
} }
......
...@@ -128,7 +128,7 @@ void ISpectrum::addDetectorID(const detid_t detID) { ...@@ -128,7 +128,7 @@ void ISpectrum::addDetectorID(const detid_t detID) {
* @param detIDs :: set of detector IDs to insert in set. * @param detIDs :: set of detector IDs to insert in set.
*/ */
void ISpectrum::addDetectorIDs(const std::set<detid_t> &detIDs) { void ISpectrum::addDetectorIDs(const std::set<detid_t> &detIDs) {
if (detIDs.size() == 0) if (detIDs.empty())
return; return;
this->detectorIDs.insert(detIDs.begin(), detIDs.end()); this->detectorIDs.insert(detIDs.begin(), detIDs.end());
} }
...@@ -138,7 +138,7 @@ void ISpectrum::addDetectorIDs(const std::set<detid_t> &detIDs) { ...@@ -138,7 +138,7 @@ void ISpectrum::addDetectorIDs(const std::set<detid_t> &detIDs) {
* @param detIDs :: vector of detector IDs to insert in set. * @param detIDs :: vector of detector IDs to insert in set.
*/ */
void ISpectrum::addDetectorIDs(const std::vector<detid_t> &detIDs) { void ISpectrum::addDetectorIDs(const std::vector<detid_t> &detIDs) {
if (detIDs.size() == 0) if (detIDs.empty())
return; return;
this->detectorIDs.insert(detIDs.begin(), detIDs.end()); this->detectorIDs.insert(detIDs.begin(), detIDs.end());
} }
......
...@@ -707,7 +707,7 @@ void MatrixWorkspace::getIntegratedSpectra(std::vector<double> &out, ...@@ -707,7 +707,7 @@ void MatrixWorkspace::getIntegratedSpectra(std::vector<double> &out,
const Mantid::MantidVec &x = this->readX(wksp_index); const Mantid::MantidVec &x = this->readX(wksp_index);
const Mantid::MantidVec &y = this->readY(wksp_index); const Mantid::MantidVec &y = this->readY(wksp_index);
// If it is a 1D workspace, no need to integrate // If it is a 1D workspace, no need to integrate
if ((x.size() <= 2) && (y.size() >= 1)) { if ((x.size() <= 2) && (!y.empty())) {
out[wksp_index] = y[0]; out[wksp_index] = y[0];
} else { } else {
// Iterators for limits - whole range by default // Iterators for limits - whole range by default
......
...@@ -45,7 +45,7 @@ void MultiDomainFunction::setDomainIndices( ...@@ -45,7 +45,7 @@ void MultiDomainFunction::setDomainIndices(
void MultiDomainFunction::countNumberOfDomains() { void MultiDomainFunction::countNumberOfDomains() {
std::set<size_t> dSet; std::set<size_t> dSet;
for (auto &domain : m_domains) { for (auto &domain : m_domains) {
if (domain.second.size()) { if (!domain.second.empty()) {
dSet.insert(domain.second.begin(), domain.second.end()); dSet.insert(domain.second.begin(), domain.second.end());
} }
} }
......
...@@ -35,7 +35,7 @@ bool MultiPeriodGroupAlgorithm::checkGroups() { ...@@ -35,7 +35,7 @@ bool MultiPeriodGroupAlgorithm::checkGroups() {
m_worker.reset(new MultiPeriodGroupWorker(propName)); m_worker.reset(new MultiPeriodGroupWorker(propName));
} }
m_multiPeriodGroups = m_worker->findMultiPeriodGroups(this); m_multiPeriodGroups = m_worker->findMultiPeriodGroups(this);
bool useDefaultGroupingBehaviour = m_multiPeriodGroups.size() == 0; bool useDefaultGroupingBehaviour = m_multiPeriodGroups.empty();
/* /*
* Give the opportunity to treat this as a regular group workspace. * Give the opportunity to treat this as a regular group workspace.
*/ */
......
...@@ -193,7 +193,7 @@ bool MultiPeriodGroupWorker::processGroups( ...@@ -193,7 +193,7 @@ bool MultiPeriodGroupWorker::processGroups(
Algorithm *const sourceAlg, Algorithm *const sourceAlg,
const VecWSGroupType &vecMultiPeriodGroups) const { const VecWSGroupType &vecMultiPeriodGroups) const {
// If we are not processing multiperiod groups, use the base behaviour. // If we are not processing multiperiod groups, use the base behaviour.
if (vecMultiPeriodGroups.size() < 1) { if (vecMultiPeriodGroups.empty()) {
return false; // Indicates that this is not a multiperiod group workspace. return false; // Indicates that this is not a multiperiod group workspace.
} }
Property *outputWorkspaceProperty = sourceAlg->getProperty("OutputWorkspace"); Property *outputWorkspaceProperty = sourceAlg->getProperty("OutputWorkspace");
......
...@@ -262,7 +262,7 @@ MultipleFileProperty::setValueAsMultipleFiles(const std::string &propValue) { ...@@ -262,7 +262,7 @@ MultipleFileProperty::setValueAsMultipleFiles(const std::string &propValue) {
// load a single (and possibly existing) file within a token, but which // load a single (and possibly existing) file within a token, but which
// has unexpected zero // has unexpected zero
// padding, or some other anomaly. // padding, or some other anomaly.
if (flattenFileNames(f).size() == 0) if (flattenFileNames(f).empty())
f.push_back(std::vector<std::string>(1, *plusTokenString)); f.push_back(std::vector<std::string>(1, *plusTokenString));
if (plusTokenStrings.size() > 1) { if (plusTokenStrings.size() > 1) {
......
...@@ -65,7 +65,7 @@ void ParameterTie::set(const std::string &expr) { ...@@ -65,7 +65,7 @@ void ParameterTie::set(const std::string &expr) {
it != m_varMap.end(); ++it) { it != m_varMap.end(); ++it) {
delete it->first; delete it->first;
} }
if (m_varMap.size()) { if (!m_varMap.empty()) {
m_varMap.clear(); m_varMap.clear();
} }
try { // Set the expression and initialize the variables try { // Set the expression and initialize the variables
...@@ -137,7 +137,7 @@ std::string ParameterTie::asString(const IFunction *fun) const { ...@@ -137,7 +137,7 @@ std::string ParameterTie::asString(const IFunction *fun) const {
try { try {
res_expression = fun->parameterName(fun->getParameterIndex(*this)) + "="; res_expression = fun->parameterName(fun->getParameterIndex(*this)) + "=";
if (m_varMap.size() == 0) { // constants if (m_varMap.empty()) { // constants
return res_expression + m_expression; return res_expression + m_expression;
; ;
} }
......
...@@ -11,7 +11,7 @@ TableRow::TableRow(const TableRowHelper &trh) ...@@ -11,7 +11,7 @@ TableRow::TableRow(const TableRowHelper &trh)
: m_row(trh.m_row), m_col(0), m_sep(",") { : m_row(trh.m_row), m_col(0), m_sep(",") {
for (size_t i = 0; i < trh.m_workspace->columnCount(); i++) for (size_t i = 0; i < trh.m_workspace->columnCount(); i++)
m_columns.push_back(trh.m_workspace->getColumn(i)); m_columns.push_back(trh.m_workspace->getColumn(i));
if (m_columns.size()) if (!m_columns.empty())
m_nrows = int(m_columns[0]->size()); m_nrows = int(m_columns[0]->size());
else else
m_nrows = 0; m_nrows = 0;
...@@ -69,7 +69,7 @@ const TableRow &TableRow::operator>>(bool &t) const { ...@@ -69,7 +69,7 @@ const TableRow &TableRow::operator>>(bool &t) const {
@return stream representation of row @return stream representation of row
*/ */
std::ostream &operator<<(std::ostream &s, const TableRow &row) { std::ostream &operator<<(std::ostream &s, const TableRow &row) {
if (row.m_columns.size() == 0) if (row.m_columns.empty())
return s; return s;
if (row.m_columns.size() == 1) { if (row.m_columns.size() == 1) {
row.m_columns[0]->print(row.row(), s); row.m_columns[0]->print(row.row(), s);
......
...@@ -328,7 +328,7 @@ Determine in the WorkspaceGroup is multiperiod. ...@@ -328,7 +328,7 @@ Determine in the WorkspaceGroup is multiperiod.
*/ */
bool WorkspaceGroup::isMultiperiod() const { bool WorkspaceGroup::isMultiperiod() const {
std::lock_guard<std::recursive_mutex> _lock(m_mutex); std::lock_guard<std::recursive_mutex> _lock(m_mutex);
if (m_workspaces.size() < 1) { if (m_workspaces.empty()) {
g_log.debug("Not a multiperiod-group with < 1 nested workspace."); g_log.debug("Not a multiperiod-group with < 1 nested workspace.");
return false; return false;
} }
......
...@@ -73,8 +73,8 @@ std::map<std::string, std::string> AsymmetryCalc::validateInputs() { ...@@ -73,8 +73,8 @@ std::map<std::string, std::string> AsymmetryCalc::validateInputs() {
void AsymmetryCalc::exec() { void AsymmetryCalc::exec() {
std::vector<int> forward_list = getProperty("ForwardSpectra"); std::vector<int> forward_list = getProperty("ForwardSpectra");
std::vector<int> backward_list = getProperty("BackwardSpectra"); std::vector<int> backward_list = getProperty("BackwardSpectra");
int forward = forward_list.size() ? forward_list[0] : 1; int forward = !forward_list.empty() ? forward_list[0] : 1;
int backward = backward_list.size() ? backward_list[0] : 2; int backward = !backward_list.empty() ? backward_list[0] : 2;
double alpha = getProperty("Alpha"); double alpha = getProperty("Alpha");
// Get original workspace // Get original workspace
......
...@@ -311,7 +311,7 @@ void CalculateFlatBackground::checkRange(double &startX, double &endX) { ...@@ -311,7 +311,7 @@ void CalculateFlatBackground::checkRange(double &startX, double &endX) {
*/ */
void CalculateFlatBackground::getSpecInds(std::vector<int> &output, void CalculateFlatBackground::getSpecInds(std::vector<int> &output,
const int workspaceTotal) { const int workspaceTotal) {
if (output.size() > 0) { if (!output.empty()) {
return; return;
} }
......
...@@ -127,12 +127,12 @@ void CalculateResolution::exec() { ...@@ -127,12 +127,12 @@ void CalculateResolution::exec() {
std::vector<double> slit1VGParam = slit1->getNumberParameter(vGapParam); std::vector<double> slit1VGParam = slit1->getNumberParameter(vGapParam);
std::vector<double> slit2VGParam = slit2->getNumberParameter(vGapParam); std::vector<double> slit2VGParam = slit2->getNumberParameter(vGapParam);
if (slit1VGParam.size() < 1) if (slit1VGParam.empty())
throw std::runtime_error("Could not find a value for the first slit's " throw std::runtime_error("Could not find a value for the first slit's "
"vertical gap with given parameter name: '" + "vertical gap with given parameter name: '" +
vGapParam + "'."); vGapParam + "'.");
if (slit2VGParam.size() < 1) if (slit2VGParam.empty())
throw std::runtime_error("Could not find a value for the second slit's " throw std::runtime_error("Could not find a value for the second slit's "
"vertical gap with given parameter name: '" + "vertical gap with given parameter name: '" +
vGapParam + "'."); vGapParam + "'.");
......
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