Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
gaoqiong
pybind11
Commits
96e6a8d5
Commit
96e6a8d5
authored
Sep 10, 2020
by
Henry Schreiner
Committed by
Henry Schreiner
Sep 15, 2020
Browse files
style: clang-tidy: readability-container-size-empty
parent
5dfbe6f9
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
7 additions
and
6 deletions
+7
-6
.clang-tidy
.clang-tidy
+1
-0
include/pybind11/cast.h
include/pybind11/cast.h
+2
-2
include/pybind11/detail/class.h
include/pybind11/detail/class.h
+2
-2
include/pybind11/pybind11.h
include/pybind11/pybind11.h
+2
-2
No files found.
.clang-tidy
View file @
96e6a8d5
...
...
@@ -4,6 +4,7 @@ Checks: '
-*,
llvm-namespace-comment,
modernize-use-override,
readability-container-size-empty,
'
HeaderFilterRegex: 'pybind11/.*h'
include/pybind11/cast.h
View file @
96e6a8d5
...
...
@@ -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"
);
...
...
include/pybind11/detail/class.h
View file @
96e6a8d5
...
...
@@ -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__ */
...
...
include/pybind11/pybind11.h
View file @
96e6a8d5
...
...
@@ -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
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment