Skip to content

Commit

Permalink
Revert "perf(linter): use OsStr for faster path comparison and hash…
Browse files Browse the repository at this point in the history
…ing (#9685)"

This reverts commit bcbb468.
  • Loading branch information
Boshen committed Mar 12, 2025
1 parent 2810e5b commit a7b6b60
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions crates/oxc_linter/src/module_graph_visitor.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{ffi::OsStr, marker::PhantomData, sync::Arc};
use std::{marker::PhantomData, path::PathBuf, sync::Arc};

use oxc_span::CompactStr;
use rustc_hash::FxHashSet;
Expand Down Expand Up @@ -124,7 +124,7 @@ impl<T> Default for ModuleGraphVisitorBuilder<'_, T> {

pub struct ModuleGraphVisitResult<T> {
pub result: T,
pub _traversed: FxHashSet<Box<OsStr>>,
pub _traversed: FxHashSet<PathBuf>,
pub _max_depth: u32,
}

Expand All @@ -136,7 +136,7 @@ impl<T> ModuleGraphVisitResult<T> {

#[derive(Debug)]
struct ModuleGraphVisitor {
traversed: FxHashSet<Box<OsStr>>,
traversed: FxHashSet<PathBuf>,
depth: u32,
max_depth: u32,
}
Expand Down Expand Up @@ -203,7 +203,7 @@ impl ModuleGraphVisitor {
}

let path = &pair.1.resolved_absolute_path;
if !self.traversed.insert(path.clone().into_os_string().into_boxed_os_str()) {
if !self.traversed.insert(path.clone()) {
continue;
}

Expand Down
6 changes: 3 additions & 3 deletions crates/oxc_linter/src/rules/import/no_cycle.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![expect(clippy::cast_possible_truncation)]
use std::{env, ffi::OsStr, path::Component, sync::Arc};
use std::{ffi::OsStr, path::Component, sync::Arc};

use cow_utils::CowUtils;
use oxc_diagnostics::OxcDiagnostic;
Expand Down Expand Up @@ -119,7 +119,7 @@ impl Rule for NoCycle {
let module_record = ctx.module_record();

let needle = &module_record.resolved_absolute_path;
let cwd = env::current_dir().unwrap();
let cwd = std::env::current_dir().unwrap();

let mut stack = Vec::new();
let ignore_types = self.ignore_types;
Expand Down Expand Up @@ -161,7 +161,7 @@ impl Rule for NoCycle {
})
.visit_fold(false, module_record, |_, (_, val), _| {
let path = &val.resolved_absolute_path;
if path.as_os_str() == needle.as_os_str() {
if path == needle {
VisitFoldWhile::Stop(true)
} else {
VisitFoldWhile::Next(false)
Expand Down

0 comments on commit a7b6b60

Please sign in to comment.