Skip to content

Commit cf451d8

Browse files
committed
revert: ty_project::Project: FxIndexSet -> FxHashSet
1 parent 3dc82b8 commit cf451d8

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

crates/ruff_benchmark/benches/ty.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use ruff_python_ast::PythonVersion;
1717
use ty_project::metadata::options::{EnvironmentOptions, Options};
1818
use ty_project::metadata::value::{RangedValue, RelativePathBuf};
1919
use ty_project::watch::{ChangeEvent, ChangedKind};
20-
use ty_project::{CheckMode, Db, FxIndexSet, ProjectDatabase, ProjectMetadata};
20+
use ty_project::{CheckMode, Db, FxHashSet, ProjectDatabase, ProjectMetadata};
2121

2222
struct Case {
2323
db: ProjectDatabase,
@@ -88,7 +88,7 @@ fn setup_tomllib_case() -> Case {
8888
});
8989

9090
let mut db = ProjectDatabase::new(metadata, system).unwrap();
91-
let mut tomllib_files = FxIndexSet::default();
91+
let mut tomllib_files = FxHashSet::default();
9292
let mut re: Option<File> = None;
9393

9494
for test_file in &TOMLLIB_FILES {
@@ -239,7 +239,7 @@ fn setup_micro_case(code: &str) -> Case {
239239

240240
db.set_check_mode(CheckMode::OpenFiles);
241241
db.project()
242-
.set_open_files(&mut db, FxIndexSet::from_iter([file]));
242+
.set_open_files(&mut db, FxHashSet::from_iter([file]));
243243

244244
let file_path = file.path(&db).as_system_path().unwrap().to_owned();
245245

crates/ty_project/src/lib.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ use tracing::error;
2929
use ty_python_semantic::add_inferred_python_version_hint_to_diagnostic;
3030
use ty_python_semantic::lint::RuleSelection;
3131
use ty_python_semantic::types::check_types;
32-
pub use ty_python_semantic::{FxIndexMap, FxIndexSet};
32+
pub use ty_python_semantic::{FxHashMap, FxHashSet};
3333

3434
mod db;
3535
mod files;
@@ -55,7 +55,7 @@ pub struct Project {
5555
/// The files that are open in the project, [`None`] if there are no open files.
5656
#[returns(ref)]
5757
#[default]
58-
open_fileset: FxIndexSet<File>,
58+
open_fileset: FxHashSet<File>,
5959

6060
/// The first-party files of this project.
6161
#[default]
@@ -354,7 +354,7 @@ impl Project {
354354
tracing::debug!("Closing file `{}`", file.path(db));
355355

356356
let mut open_files = self.take_open_files(db);
357-
let removed = open_files.swap_remove(&file);
357+
let removed = open_files.remove(&file);
358358

359359
if removed {
360360
self.set_open_files(db, open_files);
@@ -398,25 +398,25 @@ impl Project {
398398
}
399399

400400
/// Returns the open files in the project or `None` if there are no open files.
401-
pub fn open_files(self, db: &dyn Db) -> &FxIndexSet<File> {
401+
pub fn open_files(self, db: &dyn Db) -> &FxHashSet<File> {
402402
self.open_fileset(db)
403403
}
404404

405405
/// Sets the open files in the project.
406406
#[tracing::instrument(level = "debug", skip(self, db))]
407-
pub fn set_open_files(self, db: &mut dyn Db, open_files: FxIndexSet<File>) {
407+
pub fn set_open_files(self, db: &mut dyn Db, open_files: FxHashSet<File>) {
408408
tracing::debug!("Set open project files (count: {})", open_files.len());
409409

410410
self.set_open_fileset(db).to(open_files);
411411
}
412412

413413
/// This takes the open files from the project and returns them.
414-
fn take_open_files(self, db: &mut dyn Db) -> FxIndexSet<File> {
414+
fn take_open_files(self, db: &mut dyn Db) -> FxHashSet<File> {
415415
tracing::debug!("Take open project files");
416416

417417
// Salsa will cancel any pending queries and remove its own reference to `open_files`
418418
// so that the reference counter to `open_files` now drops to 1.
419-
self.set_open_fileset(db).to(FxIndexSet::default())
419+
self.set_open_fileset(db).to(FxHashSet::default())
420420
}
421421

422422
/// Returns `true` if the file should be checked.
@@ -586,7 +586,7 @@ pub(crate) fn check_file_impl(db: &dyn Db, file: File) -> Result<Box<[Diagnostic
586586

587587
#[derive(Debug)]
588588
enum ProjectFiles<'a> {
589-
OpenFiles(&'a FxIndexSet<File>),
589+
OpenFiles(&'a FxHashSet<File>),
590590
Indexed(files::Indexed<'a>),
591591
}
592592

@@ -619,14 +619,14 @@ impl<'a> IntoIterator for &'a ProjectFiles<'a> {
619619

620620
fn into_iter(self) -> Self::IntoIter {
621621
match self {
622-
ProjectFiles::OpenFiles(files) => ProjectFilesIter::OpenFiles(files.iter()),
622+
ProjectFiles::OpenFiles(files) => ProjectFilesIter::OpenFiles(files.unstable_iter()),
623623
ProjectFiles::Indexed(files) => ProjectFilesIter::Indexed(files.into_iter()),
624624
}
625625
}
626626
}
627627

628628
enum ProjectFilesIter<'db> {
629-
OpenFiles(indexmap::set::Iter<'db, File>),
629+
OpenFiles(std::collections::hash_set::Iter<'db, File>),
630630
Indexed(files::IndexedIter<'db>),
631631
}
632632

0 commit comments

Comments
 (0)