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

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

parent 9f49657e
......@@ -936,7 +936,7 @@ void RemovePeaks::setup(TableWorkspace_sptr peaktablews) {
// Check
if (m_vecPeakCentre.size() != m_vecPeakFWHM.size())
throw runtime_error("Number of peak centres and FWHMs are different!");
else if (m_vecPeakCentre.size() == 0)
else if (m_vecPeakCentre.empty())
throw runtime_error(
"There is not any peak entry in input table workspace.");
......@@ -950,7 +950,7 @@ Workspace2D_sptr
RemovePeaks::removePeaks(API::MatrixWorkspace_const_sptr dataws, int wsindex,
double numfwhm) {
// Check
if (m_vecPeakCentre.size() == 0)
if (m_vecPeakCentre.empty())
throw runtime_error("RemovePeaks has not been setup yet. ");
// Initialize vectors
......
......@@ -483,7 +483,7 @@ void LoadEventNexus::loadEntryMetadata(const std::string &nexusfilename, T WS,
// inside ISIS the run_number type is int32
std::vector<int> value;
file.getData(value);
if (value.size() > 0)
if (!value.empty())
run = boost::lexical_cast<std::string>(value[0]);
}
if (!run.empty()) {
......
......@@ -99,7 +99,7 @@ void DownloadInstrument::exec() {
return;
}
if (fileMap.size() == 0) {
if (fileMap.empty()) {
g_log.notice("All instrument definitions up to date");
} else {
std::string s = (fileMap.size() > 1) ? "s" : "";
......
......@@ -508,7 +508,7 @@ void FilterEventsByLogValuePreNexus::processProperties() {
// Load partial spectra
//---------------------------------------------------------------------------
// For slight speed up
m_loadOnlySomeSpectra = (this->m_spectraList.size() > 0);
m_loadOnlySomeSpectra = (!this->m_spectraList.empty());
// Turn the spectra list into a map, for speed of access
for (auto spectra : m_spectraList)
......
......@@ -57,7 +57,7 @@ void LoadCanSAS1D2::exec() {
if (!loadTrans)
return; // all done. It is not to load the transmission, nor check if it
// exists.
if (trans_gp.size() == 0 && trans_can_gp.size() == 0) {
if (trans_gp.empty() && trans_can_gp.empty()) {
return; // all done, not transmission inside
}
......
......@@ -109,7 +109,7 @@ void LoadDetectorsGroupingFile::exec() {
std::map<int, std::vector<detid_t>>::iterator dit;
for (dit = m_groupDetectorsMap.begin(); dit != m_groupDetectorsMap.end();
++dit) {
if (dit->second.size() > 0)
if (!dit->second.empty())
throw std::invalid_argument(
"Grouping file specifies detector ID without instrument name");
}
......@@ -192,7 +192,7 @@ void LoadDetectorsGroupingFile::setByComponents() {
bool norecord = true;
for (mapiter = m_groupComponentsMap.begin();
mapiter != m_groupComponentsMap.end(); ++mapiter) {
if (mapiter->second.size() > 0) {
if (!mapiter->second.empty()) {
g_log.error() << "Instrument is not specified in XML file. "
<< "But tag 'component' is used in XML file for Group "
<< mapiter->first << " It is not allowed" << std::endl;
......@@ -262,12 +262,12 @@ void LoadDetectorsGroupingFile::setByComponents() {
void LoadDetectorsGroupingFile::setByDetectors() {
// 0. Check
if (!m_instrument && m_groupDetectorsMap.size() > 0) {
if (!m_instrument && !m_groupDetectorsMap.empty()) {
std::map<int, std::vector<detid_t>>::iterator mapiter;
bool norecord = true;
for (mapiter = m_groupDetectorsMap.begin();
mapiter != m_groupDetectorsMap.end(); ++mapiter)
if (mapiter->second.size() > 0) {
if (!mapiter->second.empty()) {
norecord = false;
g_log.error() << "Instrument is not specified in XML file. "
<< "But tag 'detid' is used in XML file for Group "
......
......@@ -515,7 +515,7 @@ public:
std::string thisStartTime = "";
size_t thisNumPulses = 0;
file.getAttr("offset", thisStartTime);
if (file.getInfo().dims.size() > 0)
if (!file.getInfo().dims.empty())
thisNumPulses = file.getInfo().dims[0];
file.closeData();
......@@ -2149,7 +2149,7 @@ void LoadEventNexus::deleteBanks(EventWorkspaceCollection_sptr workspace,
}
}
}
if (detList.size() == 0)
if (detList.empty())
return;
for (auto &det : detList) {
bool keep = false;
......
......@@ -476,7 +476,7 @@ void LoadEventPreNexus::procEvents(
}
// For slight speed up
loadOnlySomeSpectra = (this->spectra_list.size() > 0);
loadOnlySomeSpectra = (!this->spectra_list.empty());
// Turn the spectra list into a map, for speed of access
for (auto &spectrum : spectra_list)
......
......@@ -726,7 +726,7 @@ void LoadEventPreNexus2::procEvents(
}
// For slight speed up
loadOnlySomeSpectra = (this->spectra_list.size() > 0);
loadOnlySomeSpectra = (!this->spectra_list.empty());
// Turn the spectra list into a map, for speed of access
for (auto &spectrum : spectra_list)
......
......@@ -138,7 +138,7 @@ void LoadFullprofResolution::exec() {
if (vec_bankinirf.empty()) {
throw runtime_error("No Bank is found in input file.");
} else if (outputbankids.size() == 0) {
} else if (outputbankids.empty()) {
vec_bankids = vec_bankinirf;
// If workspaces, set up Bank-Workpace correspondence
if (wsg)
......@@ -177,7 +177,7 @@ void LoadFullprofResolution::exec() {
}
}
}
if (vec_bankids.size() == 0) {
if (vec_bankids.empty()) {
g_log.error("There is no valid specified bank IDs for output.");
throw runtime_error("There is no valid specified bank IDs for output.");
}
......@@ -208,7 +208,7 @@ void LoadFullprofResolution::exec() {
if (wsg) {
// First check that number of workspaces in group matches number of banks,
// if no WorkspacesForBanks is specified.
if ((outputwsids.size() == 0) && (wsg->size() != vec_bankids.size())) {
if ((outputwsids.empty()) && (wsg->size() != vec_bankids.size())) {
std::ostringstream mess;
mess << "Number of banks (" << vec_bankids.size()
<< ") does not match number of workspaces (" << wsg->size()
......@@ -786,7 +786,7 @@ TableWorkspace_sptr LoadFullprofResolution::genTableWorkspace(
void LoadFullprofResolution::createBankToWorkspaceMap(
const std::vector<int> &banks, const std::vector<int> &workspaces,
std::map<int, size_t> &workspaceOfBank) {
if (workspaces.size() == 0) {
if (workspaces.empty()) {
for (size_t i = 0; i < banks.size(); i++) {
workspaceOfBank.emplace(banks[i], i + 1);
}
......
......@@ -132,7 +132,7 @@ void LoadGSASInstrumentFile::exec() {
vector<size_t> bankStartIndex;
scanBanks(lines, bankStartIndex);
if (bankStartIndex.size() == 0) {
if (bankStartIndex.empty()) {
throw std::runtime_error("No nanks found in file. \n");
}
......@@ -172,7 +172,7 @@ void LoadGSASInstrumentFile::exec() {
map<int, size_t> workspaceOfBank;
// Deal with bankIds
if (bankIds.size()) {
if (!bankIds.empty()) {
// If user provided a list of banks, check that they exist in the .prm
// file
for (auto bankId : bankIds) {
......
......@@ -225,7 +225,7 @@ API::MatrixWorkspace_sptr LoadGSS::loadGSASFile(const std::string &filename,
// If there is, Save the previous to array and initialze new MantiVec for
// (X, Y, E)
if (vecX.size() != 0) {
if (!vecX.empty()) {
std::vector<double> storeX = vecX;
std::vector<double> storeY = vecY;
std::vector<double> storeE = vecE;
......@@ -297,7 +297,7 @@ API::MatrixWorkspace_sptr LoadGSS::loadGSASFile(const std::string &filename,
double xPrev;
// * Get previous X value
if (vecX.size() != 0) {
if (!vecX.empty()) {
xPrev = vecX.back();
} else if (filetype == 'r') {
// Except if RALF
......@@ -370,7 +370,7 @@ API::MatrixWorkspace_sptr LoadGSS::loadGSASFile(const std::string &filename,
} // ENDWHILE of readling all lines
// Push the vectors (X, Y, E) of the last bank to gsasData
if (vecX.size() != 0) { // Put final spectra into data
if (!vecX.empty()) { // Put final spectra into data
gsasDataX.push_back(vecX);
gsasDataY.push_back(vecY);
gsasDataE.push_back(vecE);
......
......@@ -538,7 +538,7 @@ void LoadISISNexus2::checkOptionalProperties(
spec_list.erase(remove_if(spec_list.begin(), spec_list.end(), in_range),
spec_list.end());
// combine spectra numbers from ranges and the list
if (spec_list.size() > 0) {
if (!spec_list.empty()) {
for (int64_t i = spec_min; i < spec_max + 1; i++) {
specnum_t spec_num = static_cast<specnum_t>(i);
// remove excluded spectra now rather then inserting it here and
......@@ -582,7 +582,7 @@ void LoadISISNexus2::buildSpectraInd2SpectraNumMap(
int64_t ic(0);
if (spec_list.size() > 0) {
if (!spec_list.empty()) {
ic = 0;
auto start_point = spec_list.begin();
for (auto it = start_point; it != spec_list.end(); it++) {
......
......@@ -322,7 +322,7 @@ void LoadMask::processMaskOnWorkspaceIndex(bool mask,
std::vector<int32_t> pairslow,
std::vector<int32_t> pairsup) {
// 1. Check
if (pairslow.size() == 0)
if (pairslow.empty())
return;
if (pairslow.size() != pairsup.size()) {
g_log.error() << "Input spectrum IDs are not paired. Size(low) = "
......
......@@ -2157,7 +2157,7 @@ LoadNexusProcessed::calculateWorkspaceSize(const std::size_t numberofspectra,
} else
++it;
}
if (m_spec_list.size() == 0)
if (m_spec_list.empty())
m_list = false;
total_specs += static_cast<int>(m_spec_list.size());
......
......@@ -309,7 +309,7 @@ void LoadPDFgetNFile::setUnit(Workspace2D_sptr ws) {
*/
void LoadPDFgetNFile::generateDataWorkspace() {
// 0. Check
if (mData.size() == 0) {
if (mData.empty()) {
throw runtime_error("Data set has not been initialized. Quit!");
}
......
......@@ -918,7 +918,7 @@ void LoadRawHelper::checkOptionalProperties() {
// Check validity of spectra list property, if set
if (m_list) {
m_list = true;
if (m_spec_list.size() == 0) {
if (m_spec_list.empty()) {
m_list = false;
} else {
const int64_t minlist =
......@@ -968,7 +968,7 @@ specnum_t LoadRawHelper::calculateWorkspaceSize() {
} else
++it;
}
if (m_spec_list.size() == 0)
if (m_spec_list.empty())
m_list = false;
total_specs += static_cast<specnum_t>(m_spec_list.size());
m_total_specs = total_specs;
......@@ -1025,7 +1025,7 @@ void LoadRawHelper::calculateWorkspacesizes(
else
++itr;
}
if (m_spec_list.size() == 0) {
if (m_spec_list.empty()) {
g_log.debug() << "normalwsSpecs is " << normalwsSpecs
<< " monitorwsSpecs is " << monitorwsSpecs
<< std::endl;
......
......@@ -208,7 +208,7 @@ size_t LoadReflTBL::getCells(std::string line,
findQuotePairs(line, quoteBounds);
// if we didn't find any quotes, then there are too many commas and we
// definitely have too many delimiters
if (quoteBounds.size() == 0) {
if (quoteBounds.empty()) {
std::string message =
"A line must contain 16 cell-delimiting commas. Found " +
boost::lexical_cast<std::string>(found) + ".";
......
......@@ -412,7 +412,7 @@ void LoadSassena::exec() {
// Block to read the Q-vectors
std::vector<int> sorting_indexes;
const MantidVec qvmod = this->loadQvectors(h5file, gws, sorting_indexes);
if (qvmod.size() == 0) {
if (qvmod.empty()) {
this->g_log.error("No Q-vectors read. Unable to proceed");
H5Fclose(h5file);
return;
......
......@@ -445,7 +445,7 @@ void LoadSpiceAscii::setupRunStartTime(
API::MatrixWorkspace_sptr runinfows,
const std::vector<std::string> &datetimeprop) {
// Check if no need to process run start time
if (datetimeprop.size() == 0) {
if (datetimeprop.empty()) {
g_log.information("User chooses not to set up run start date and time.");
return;
}
......
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