Skip to content

Commit f067deb

Browse files
authored
avoid unnecessary strlen (#3058)
1 parent 733f8de commit f067deb

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

include/pybind11/attr.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ template <> struct process_attribute<is_new_style_constructor> : process_attribu
377377
};
378378

379379
inline void process_kw_only_arg(const arg &a, function_record *r) {
380-
if (!a.name || strlen(a.name) == 0)
380+
if (!a.name || a.name[0] == '\0')
381381
pybind11_fail("arg(): cannot specify an unnamed argument after an kw_only() annotation");
382382
++r->nargs_kw_only;
383383
}

include/pybind11/pybind11.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ class cpp_function : public function {
470470
signatures += it->signature;
471471
signatures += "\n";
472472
}
473-
if (it->doc && strlen(it->doc) > 0 && options::show_user_defined_docstrings()) {
473+
if (it->doc && it->doc[0] != '\0' && options::show_user_defined_docstrings()) {
474474
// If we're appending another docstring, and aren't printing function signatures, we
475475
// need to append a newline first:
476476
if (!options::show_function_signatures()) {

0 commit comments

Comments
 (0)