mirror of
https://github.com/astral-sh/ruff
synced 2026-01-23 06:20:55 -05:00
Improve Message sorting performance (#4624)
This commit is contained in:
@@ -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>,
|
||||
|
||||
Reference in New Issue
Block a user