mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-04 02:38:25 +00:00
Avoid allocation in no-signature (#6375)
This commit is contained in:
parent
a5a29bb8d6
commit
9171e97d15
1 changed files with 10 additions and 7 deletions
|
@ -72,11 +72,14 @@ pub(crate) fn no_signature(checker: &mut Checker, docstring: &Docstring) {
|
|||
return;
|
||||
};
|
||||
|
||||
if !first_line.contains(&format!("{name}(")) {
|
||||
return;
|
||||
};
|
||||
|
||||
checker
|
||||
.diagnostics
|
||||
.push(Diagnostic::new(NoSignature, docstring.range()));
|
||||
// Search for occurrences of the function name followed by an open parenthesis (e.g., `foo(` for
|
||||
// a function named `foo`).
|
||||
if first_line
|
||||
.match_indices(name.as_str())
|
||||
.any(|(index, _)| first_line[index + name.len()..].starts_with('('))
|
||||
{
|
||||
checker
|
||||
.diagnostics
|
||||
.push(Diagnostic::new(NoSignature, docstring.range()));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue