mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-16 00:20:38 +00:00
Improve Message
sorting performance (#4624)
This commit is contained in:
parent
17d938f078
commit
85f094f592
4 changed files with 23 additions and 10 deletions
|
@ -1,3 +1,4 @@
|
|||
use std::cmp::Ordering;
|
||||
use std::fmt::{Debug, Formatter};
|
||||
use std::sync::Arc;
|
||||
|
||||
|
@ -207,6 +208,23 @@ impl SourceFile {
|
|||
}
|
||||
}
|
||||
|
||||
impl PartialOrd for SourceFile {
|
||||
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
|
||||
Some(self.cmp(other))
|
||||
}
|
||||
}
|
||||
|
||||
impl Ord for SourceFile {
|
||||
fn cmp(&self, other: &Self) -> Ordering {
|
||||
// Short circuit if these are the same source files
|
||||
if Arc::ptr_eq(&self.inner, &other.inner) {
|
||||
Ordering::Equal
|
||||
} else {
|
||||
self.inner.name.cmp(&other.inner.name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct SourceFileInner {
|
||||
name: Box<str>,
|
||||
code: Box<str>,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue