mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-22 13:15:12 +00:00
style: clang-tidy: readability-container-size-empty
This commit is contained in:
parent
5dfbe6f903
commit
96e6a8d554
@ -4,6 +4,7 @@ Checks: '
|
||||
-*,
|
||||
llvm-namespace-comment,
|
||||
modernize-use-override,
|
||||
readability-container-size-empty,
|
||||
'
|
||||
|
||||
HeaderFilterRegex: 'pybind11/.*h'
|
||||
|
@ -59,7 +59,7 @@ public:
|
||||
Py_CLEAR(ptr);
|
||||
|
||||
// A heuristic to reduce the stack's capacity (e.g. after long recursive calls)
|
||||
if (stack.capacity() > 16 && stack.size() != 0 && stack.capacity() / stack.size() > 2)
|
||||
if (stack.capacity() > 16 && !stack.empty() && stack.capacity() / stack.size() > 2)
|
||||
stack.shrink_to_fit();
|
||||
}
|
||||
|
||||
@ -163,7 +163,7 @@ inline const std::vector<detail::type_info *> &all_type_info(PyTypeObject *type)
|
||||
*/
|
||||
PYBIND11_NOINLINE inline detail::type_info* get_type_info(PyTypeObject *type) {
|
||||
auto &bases = all_type_info(type);
|
||||
if (bases.size() == 0)
|
||||
if (bases.empty())
|
||||
return nullptr;
|
||||
if (bases.size() > 1)
|
||||
pybind11_fail("pybind11::detail::get_type_info: type has multiple pybind11-registered bases");
|
||||
|
@ -592,7 +592,7 @@ inline PyObject* make_new_python_type(const type_record &rec) {
|
||||
|
||||
auto &internals = get_internals();
|
||||
auto bases = tuple(rec.bases);
|
||||
auto base = (bases.size() == 0) ? internals.instance_base
|
||||
auto base = (bases.empty()) ? internals.instance_base
|
||||
: bases[0].ptr();
|
||||
|
||||
/* Danger zone: from now (and until PyType_Ready), make sure to
|
||||
@ -616,7 +616,7 @@ inline PyObject* make_new_python_type(const type_record &rec) {
|
||||
type->tp_doc = tp_doc;
|
||||
type->tp_base = type_incref((PyTypeObject *)base);
|
||||
type->tp_basicsize = static_cast<ssize_t>(sizeof(instance));
|
||||
if (bases.size() > 0)
|
||||
if (!bases.empty())
|
||||
type->tp_bases = bases.release().ptr();
|
||||
|
||||
/* Don't inherit base __init__ */
|
||||
|
@ -626,7 +626,7 @@ protected:
|
||||
}
|
||||
|
||||
// 3. Check everything was consumed (unless we have a kwargs arg)
|
||||
if (kwargs && kwargs.size() > 0 && !func.has_kwargs)
|
||||
if (kwargs && !kwargs.empty() && !func.has_kwargs)
|
||||
continue; // Unconsumed kwargs, but no py::kwargs argument to accept them
|
||||
|
||||
// 4a. If we have a py::args argument, create a new tuple with leftovers
|
||||
@ -814,7 +814,7 @@ protected:
|
||||
}
|
||||
if (kwargs_in) {
|
||||
auto kwargs = reinterpret_borrow<dict>(kwargs_in);
|
||||
if (kwargs.size() > 0) {
|
||||
if (!kwargs.empty()) {
|
||||
if (some_args) msg += "; ";
|
||||
msg += "kwargs: ";
|
||||
bool first = true;
|
||||
|
Loading…
Reference in New Issue
Block a user