Skip to content

Commit d563856

Browse files
committed
refactor(oxfmt): Pass PathBuf from walk.rs to service.rs
1 parent de7588d commit d563856

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

apps/oxfmt/src/service.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ impl FormatService {
4444
fn process_entry(&self, entry: &WalkEntry, tx_error: &DiagnosticSender) {
4545
let start_time = Instant::now();
4646

47-
let path = Path::new(&entry.path);
47+
let path = &entry.path;
4848
let source_type = enable_jsx_source_type(entry.source_type);
4949

5050
// TODO: Use `read_to_arena_str()` like `oxlint`?
@@ -69,7 +69,7 @@ impl FormatService {
6969
&source_text,
7070
ret.errors,
7171
);
72-
tx_error.send((path.to_path_buf(), diagnostics)).unwrap();
72+
tx_error.send((path.clone(), diagnostics)).unwrap();
7373
return;
7474
}
7575

@@ -106,7 +106,7 @@ impl FormatService {
106106
))),
107107
_ => None,
108108
} {
109-
tx_error.send((path.to_path_buf(), vec![diagnostic.into()])).unwrap();
109+
tx_error.send((path.clone(), vec![diagnostic.into()])).unwrap();
110110
}
111111
}
112112
}

apps/oxfmt/src/walk.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::{ffi::OsStr, path::PathBuf, sync::Arc, sync::mpsc};
1+
use std::{ffi::OsStr, path::PathBuf, sync::mpsc};
22

33
use ignore::overrides::Override;
44

@@ -58,7 +58,7 @@ impl Walk {
5858
}
5959

6060
pub struct WalkEntry {
61-
pub path: Arc<OsStr>,
61+
pub path: PathBuf,
6262
pub source_type: SourceType,
6363
}
6464

@@ -112,8 +112,7 @@ impl ignore::ParallelVisitor for WalkVisitor {
112112
}
113113

114114
if let Some(source_type) = get_supported_source_type(entry.path()) {
115-
let walk_entry =
116-
WalkEntry { path: entry.path().as_os_str().into(), source_type };
115+
let walk_entry = WalkEntry { path: entry.path().to_path_buf(), source_type };
117116
// Send each entry immediately through the channel
118117
// If send fails, the receiver has been dropped, so stop walking
119118
if self.sender.send(walk_entry).is_err() {

0 commit comments

Comments
 (0)