Skip to content

Use memchr for tab-indentation detection#9853

Merged
charliermarsh merged 1 commit into
mainfrom
charlie/tabs
Feb 6, 2024
Merged

Use memchr for tab-indentation detection#9853
charliermarsh merged 1 commit into
mainfrom
charlie/tabs

Conversation

@charliermarsh
Copy link
Copy Markdown
Member

@charliermarsh charliermarsh commented Feb 6, 2024

Summary

The benchmarks show a pretty consistent 1% speedup here for all-rules, though not enough to trigger our threshold of course:

Screenshot 2024-02-05 at 11 55 59 PM

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Feb 6, 2024

ruff-ecosystem results

Linter (stable)

ℹ️ ecosystem check encountered linter errors. (no lint changes; 1 project error)

sphinx-doc/sphinx (error)

ruff failed
  Cause: Selection of unstable rules without the `--preview` flag is not allowed. Enable preview or remove selection of:
	- FURB113
	- FURB131
	- FURB132

Linter (preview)

✅ ecosystem check detected no linter changes.

@charliermarsh charliermarsh changed the title Try fast-path for tab detection Use memchr for tab-indentation detection Feb 6, 2024
@charliermarsh charliermarsh marked this pull request as ready for review February 6, 2024 04:56
@charliermarsh charliermarsh added the performance Potential performance improvement label Feb 6, 2024
Comment on lines +87 to +89
if !indexer.multiline_ranges().contains_range(range) {
return Some(range);
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: I believe the rule will now have a false positive for

a = "b\
		test"

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I swear I tested this and it wasn't valid but you're totally right. Regardless, we need to solve this for the trailing whitespace rule too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

performance Potential performance improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants