avoid unnecessary strlen (#3058)

This commit is contained in:
cyy 2021-07-01 14:35:25 +08:00 committed by GitHub
parent 733f8de24f
commit f067deb563
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View File

@ -377,7 +377,7 @@ template <> struct process_attribute<is_new_style_constructor> : process_attribu
};
inline void process_kw_only_arg(const arg &a, function_record *r) {
if (!a.name || strlen(a.name) == 0)
if (!a.name || a.name[0] == '\0')
pybind11_fail("arg(): cannot specify an unnamed argument after an kw_only() annotation");
++r->nargs_kw_only;
}

View File

@ -470,7 +470,7 @@ protected:
signatures += it->signature;
signatures += "\n";
}
if (it->doc && strlen(it->doc) > 0 && options::show_user_defined_docstrings()) {
if (it->doc && it->doc[0] != '\0' && options::show_user_defined_docstrings()) {
// If we're appending another docstring, and aren't printing function signatures, we
// need to append a newline first:
if (!options::show_function_signatures()) {