Remove lexer-based comment range detection (#5785)

## Summary

I'm doing some unrelated profiling, and I noticed that this method is
actually measurable on the CPython benchmark -- it's > 1% of execution
time. We don't need to lex here, we already know the ranges of all
comments, so we can just do a simple binary search for overlap, which
brings the method down to 0%.

## Test Plan

`cargo test`
This commit is contained in:
Charlie Marsh 2023-07-15 21:03:27 -04:00 committed by GitHub
parent f2e995f78d
commit 4782675bf9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 44 additions and 44 deletions

View file

@ -93,7 +93,7 @@ impl Indexer {
}
/// Returns the byte offset ranges of comments
pub fn comment_ranges(&self) -> &CommentRanges {
pub const fn comment_ranges(&self) -> &CommentRanges {
&self.comment_ranges
}