Make SanitizedPath wrap Path instead of Arc<Path> to avoid allocation (#37106)
Release Notes: - N/A
This commit is contained in:
+5
-3
@@ -495,7 +495,8 @@ impl Fs for RealFs {
|
||||
};
|
||||
// todo(windows)
|
||||
// When new version of `windows-rs` release, make this operation `async`
|
||||
let path = SanitizedPath::from(path.canonicalize()?);
|
||||
let path = path.canonicalize()?;
|
||||
let path = SanitizedPath::new(&path);
|
||||
let path_string = path.to_string();
|
||||
let file = StorageFile::GetFileFromPathAsync(&HSTRING::from(path_string))?.get()?;
|
||||
file.DeleteAsync(StorageDeleteOption::Default)?.get()?;
|
||||
@@ -522,7 +523,8 @@ impl Fs for RealFs {
|
||||
|
||||
// todo(windows)
|
||||
// When new version of `windows-rs` release, make this operation `async`
|
||||
let path = SanitizedPath::from(path.canonicalize()?);
|
||||
let path = path.canonicalize()?;
|
||||
let path = SanitizedPath::new(&path);
|
||||
let path_string = path.to_string();
|
||||
let folder = StorageFolder::GetFolderFromPathAsync(&HSTRING::from(path_string))?.get()?;
|
||||
folder.DeleteAsync(StorageDeleteOption::Default)?.get()?;
|
||||
@@ -783,7 +785,7 @@ impl Fs for RealFs {
|
||||
{
|
||||
target = parent.join(target);
|
||||
if let Ok(canonical) = self.canonicalize(&target).await {
|
||||
target = SanitizedPath::from(canonical).as_path().to_path_buf();
|
||||
target = SanitizedPath::new(&canonical).as_path().to_path_buf();
|
||||
}
|
||||
}
|
||||
watcher.add(&target).ok();
|
||||
|
||||
@@ -42,7 +42,7 @@ impl Drop for FsWatcher {
|
||||
|
||||
impl Watcher for FsWatcher {
|
||||
fn add(&self, path: &std::path::Path) -> anyhow::Result<()> {
|
||||
let root_path = SanitizedPath::from(path);
|
||||
let root_path = SanitizedPath::new_arc(path);
|
||||
|
||||
let tx = self.tx.clone();
|
||||
let pending_paths = self.pending_path_events.clone();
|
||||
@@ -70,7 +70,7 @@ impl Watcher for FsWatcher {
|
||||
.paths
|
||||
.iter()
|
||||
.filter_map(|event_path| {
|
||||
let event_path = SanitizedPath::from(event_path);
|
||||
let event_path = SanitizedPath::new(event_path);
|
||||
event_path.starts_with(&root_path).then(|| PathEvent {
|
||||
path: event_path.as_path().to_path_buf(),
|
||||
kind,
|
||||
|
||||
Reference in New Issue
Block a user