Skip to content

Commit

Permalink
PERF: readability container size empty
Browse files Browse the repository at this point in the history
The emptiness of a container should be checked using the empty() method
instead of the size() method. It is not guaranteed that size() is a
constant-time function, and it is generally more efficient and also
shows clearer intent to use empty(). Furthermore some containers may
implement the empty() method but not implement the size() method. Using
empty() whenever possible makes it easier to switch to another container
in the future.

SRCDIR= #My local SRC
BLDDIR= #My local BLD

cd
run-clang-tidy.py -extra-arg=-D__clang__ -checks=-*,readability-container-size-empty  -header-filter=.* -fix
  • Loading branch information
hjmjohnson committed Mar 1, 2020
1 parent 3b40d22 commit 0ea874c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion include/itkSpeedFunctionToPathFilter.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ SpeedFunctionToPathFilter<TInputImage, TOutputPath>::GenerateData()
}

// Ensure the user has added at least one path info object
if (m_Information.size() == 0)
if (m_Information.empty())
{
itkExceptionMacro("No PathInfo objects: at least one must be added.");
}
Expand Down

0 comments on commit 0ea874c

Please sign in to comment.