Commit 73e0a504 authored by Sean McBride's avatar Sean McBride

apply clang-tidy readability-container-size-empty, with some manual tweaks

parent 1a46bd65
......@@ -149,7 +149,7 @@ struct FieldInfo
int cc = 0;
for (const auto& cname : this->ComponentNames)
{
if (cname.size())
if (!cname.empty())
{
array->SetComponentName(cc, cname.c_str());
}
......@@ -766,7 +766,7 @@ const char* vtkDataSetAttributesFieldList::GetFieldName(int i) const
VTK_LEGACY_BODY(vtkDataSetAttributesFieldList::GetNumberOfFields, "VTK 8.2");
const auto& internals = *this->Internals;
const auto* finfo = internals.GetLegacyFieldForIndex(i);
return finfo && finfo->Name.size() ? finfo->Name.c_str() : nullptr;
return (finfo && !finfo->Name.empty()) ? finfo->Name.c_str() : nullptr;
}
#endif
......
......@@ -167,11 +167,11 @@ class vtkSelection::vtkInternals
bool ApplyBack(
std::vector<char>& op_stack, std::vector<std::shared_ptr<parser::Node> >& var_stack) const
{
assert(op_stack.size() > 0);
assert(!op_stack.empty());
if (op_stack.back() == '!')
{
if (var_stack.size() < 1)
if (var_stack.empty())
{
// failed
return false;
......@@ -256,7 +256,7 @@ public:
case '|':
case '&':
case '!':
if (accumated_text.size())
if (!accumated_text.empty())
{
parts.push_back(accumated_text);
accumated_text.clear();
......@@ -272,7 +272,7 @@ public:
break;
}
}
if (accumated_text.size())
if (!accumated_text.empty())
{
parts.push_back(accumated_text);
}
......@@ -289,10 +289,10 @@ public:
{
// apply operators till we encounter the opening paren.
while (
op_stack.size() > 0 && op_stack.back() != '(' && this->ApplyBack(op_stack, var_stack))
!op_stack.empty() && op_stack.back() != '(' && this->ApplyBack(op_stack, var_stack))
{
}
if (op_stack.size() == 0)
if (op_stack.empty())
{
// missing opening paren???
return nullptr;
......@@ -303,7 +303,7 @@ public:
}
else if (term[0] == '&' || term[0] == '|' || term[0] == '!')
{
while (op_stack.size() > 0 && (precedence(term[0]) < precedence(op_stack.back())) &&
while (!op_stack.empty() && (precedence(term[0]) < precedence(op_stack.back())) &&
this->ApplyBack(op_stack, var_stack))
{
}
......@@ -488,7 +488,7 @@ void vtkSelection::RemoveNode(vtkSelectionNode* node)
void vtkSelection::RemoveAllNodes()
{
vtkInternals& internals = (*this->Internals);
if (internals.Items.size())
if (!internals.Items.empty())
{
internals.Items.clear();
this->Modified();
......@@ -675,7 +675,7 @@ vtkSmartPointer<vtkSignedCharArray> vtkSelection::Evaluate(
}
auto tree = this->Internals->BuildExpressionTree(expr, values_map);
if (tree && (values_map.size() > 0))
if (tree && (!values_map.empty()))
{
auto result = vtkSmartPointer<vtkSignedCharArray>::New();
result->SetNumberOfComponents(1);
......
......@@ -79,7 +79,7 @@ void vtkExtractCellsByType::RemoveCellType(unsigned int cellType)
//----------------------------------------------------------------------------
void vtkExtractCellsByType::RemoveAllCellTypes()
{
if ( this->CellTypes->size() > 0 )
if ( !this->CellTypes->empty() )
{
this->CellTypes->clear();
this->Modified();
......@@ -380,7 +380,7 @@ int vtkExtractCellsByType::RequestData(
// Handle the trivial case
vtkIdType numCells = input->GetNumberOfCells();
if ( this->CellTypes->size() <= 0 || numCells <= 0 )
if ( this->CellTypes->empty() || numCells <= 0 )
{
output->Initialize(); //output is empty
return 1;
......
......@@ -174,7 +174,7 @@ public:
do
{
// Check if we have an input available, if so, return it.
if (this->Inputs.size() > 0)
if (!this->Inputs.empty())
{
InputValueType& input = this->Inputs.front();
image = input.Image;
......
......@@ -730,11 +730,11 @@ public:
else if (polyDataCount == 1)
{
vtkPolyData* data = nullptr;
if (imageURIToPolyData.size() > 0)
if (!imageURIToPolyData.empty())
{
data = imageURIToPolyData.begin()->second;
}
else if (materialIndexToPolyData.size() > 0)
else if (!materialIndexToPolyData.empty())
{
data = materialIndexToPolyData.begin()->second;
}
......
......@@ -584,8 +584,8 @@ int vtkNrrdReader::ReadHeader(vtkCharArray *headerBuffer)
// If the fastest changing dimension is 9 or less we consider that a tuple.
// We will also consider any 4th dimension as a tuple.
if ( (dimSizes.size() > 3)
|| ((dimSizes.size() > 0) && (dimSizes[0] <= 9))
|| ((dimSpacing.size() > 0) && (dimSpacing[0] == 0)) )
|| ((!dimSizes.empty()) && (dimSizes[0] <= 9))
|| ((!dimSpacing.empty()) && (dimSpacing[0] == 0)) )
{
this->NumberOfScalarComponents = dimSizes[0];
dimSizes.erase(dimSizes.begin());
......
......@@ -173,7 +173,7 @@ int vtkSEPReader::ReadHeader()
else if (key == "in")
{
std::string path = vtksys::SystemTools::GetFilenamePath(this->FileName);
if (path == "")
if (path.empty())
{
this->DataFile = value;
}
......
......@@ -73,7 +73,7 @@ int vtkMultiNewickTreeReader::ReadMeshSimple(const std::string& fname,
{
vtkDebugMacro(<<"Reading Multiple Newick trees ...");
if(fname.empty() || fname == "")
if(fname.empty())
{
vtkErrorMacro(<<"Input filename not set");
return 1;
......
......@@ -880,7 +880,7 @@ void vtkCompositeMapperHelper2::ProcessSelectorPixelBuffers(
return;
}
if (PickPixels.size() == 0 && pixeloffsets.size())
if (PickPixels.empty() && !pixeloffsets.empty())
{
// preprocess the image to find matching pixels and
// store them in a map of vectors based on flat index
......@@ -920,7 +920,7 @@ void vtkCompositeMapperHelper2::ProcessSelectorPixelBuffers(
// for each block update the image
for (dataIter it = this->Data.begin(); it != this->Data.end(); ++it)
{
if (this->PickPixels[it->second->FlatIndex].size())
if (!this->PickPixels[it->second->FlatIndex].empty())
{
this->ProcessCompositePixelBuffers(sel, prop, it->second,
this->PickPixels[it->second->FlatIndex]);
......
......@@ -1144,7 +1144,7 @@ void vtkOpenGLPointGaussianMapper::ProcessSelectorPixelBuffers(
return;
}
if (PickPixels.size() == 0 && pixeloffsets.size())
if (PickPixels.empty() && !pixeloffsets.empty())
{
// preprocess the image to find matching pixels and
// store them in a map of vectors based on flat index
......@@ -1184,7 +1184,7 @@ void vtkOpenGLPointGaussianMapper::ProcessSelectorPixelBuffers(
// for each block update the image
for (auto hiter = this->Helpers.begin(); hiter != this->Helpers.end(); ++hiter)
{
if (this->PickPixels[(*hiter)->FlatIndex].size())
if (!this->PickPixels[(*hiter)->FlatIndex].empty())
{
(*hiter)->ProcessSelectorPixelBuffers(sel,
this->PickPixels[(*hiter)->FlatIndex], prop);
......
......@@ -3491,7 +3491,7 @@ void vtkOpenGLPolyDataMapper::ProcessSelectorPixelBuffers(
inval = convertToCells(offset, stride, inval);
}
vtkIdType outval = inval;
if (this->CellCellMap.size())
if (!this->CellCellMap.empty())
{
outval = this->CellCellMap[outval];
}
......@@ -3534,7 +3534,7 @@ void vtkOpenGLPolyDataMapper::ProcessSelectorPixelBuffers(
inval = convertToCells(offset, stride, inval);
}
vtkIdType outval = inval;
if (this->CellCellMap.size())
if (!this->CellCellMap.empty())
{
outval = this->CellCellMap[outval];
}
......
Markdown is supported
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