Skip to content

Commit 9b84c23

Browse files
authored
chore(bench): FileSystemOs uses std::fs instead of tokio::fs (#275)
1 parent 5469887 commit 9b84c23

2 files changed

Lines changed: 11 additions & 15 deletions

File tree

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ document-features = { version = "0.2.12", optional = true }
100100
futures = "0.3.32"
101101

102102
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
103-
tokio = { version = "1.52.3", default-features = false, features = ["sync", "rt-multi-thread", "macros", "fs"] }
103+
tokio = { version = "1.52.3", default-features = false, features = ["sync", "rt-multi-thread", "macros"] }
104104
[target.'cfg(target_arch = "wasm32")'.dependencies]
105105
tokio = { version = "1.52.3", default-features = false, features = ["sync", "rt", "macros"] }
106106

src/file_system.rs

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -153,13 +153,13 @@ impl FileSystem for FileSystemOs {
153153
if self.options.enable_pnp {
154154
return match VPath::from(path)? {
155155
VPath::Zip(info) => self.pnp_lru.read(info.physical_base_path(), info.zip_path),
156-
VPath::Virtual(info) => tokio::fs::read(info.physical_base_path()).await,
157-
VPath::Native(path) => tokio::fs::read(&path).await,
156+
VPath::Virtual(info) => fs::read(info.physical_base_path()),
157+
VPath::Native(path) => fs::read(&path),
158158
}
159159
}
160160
}}
161161

162-
tokio::fs::read(path).await
162+
fs::read(path)
163163
}
164164

165165
async fn read_to_string(&self, path: &Path) -> io::Result<String> {
@@ -168,13 +168,13 @@ impl FileSystem for FileSystemOs {
168168
if self.options.enable_pnp {
169169
return match VPath::from(path)? {
170170
VPath::Zip(info) => self.pnp_lru.read_to_string(info.physical_base_path(), info.zip_path),
171-
VPath::Virtual(info) => tokio::fs::read_to_string(info.physical_base_path()).await,
172-
VPath::Native(path) => tokio::fs::read_to_string(&path).await,
171+
VPath::Virtual(info) => fs::read_to_string(info.physical_base_path()),
172+
VPath::Native(path) => fs::read_to_string(&path),
173173
}
174174
}
175175
}
176176
}
177-
tokio::fs::read_to_string(path).await
177+
fs::read_to_string(path)
178178
}
179179

180180
async fn metadata(&self, path: &Path) -> io::Result<FileMetadata> {
@@ -187,23 +187,19 @@ impl FileSystem for FileSystemOs {
187187
.file_type(info.physical_base_path(), info.zip_path)
188188
.map(FileMetadata::from),
189189
VPath::Virtual(info) => {
190-
tokio::fs::metadata(info.physical_base_path())
191-
.await
192-
.map(FileMetadata::from)
190+
fs::metadata(info.physical_base_path()).map(FileMetadata::from)
193191
}
194-
VPath::Native(path) => tokio::fs::metadata(path).await.map(FileMetadata::from),
192+
VPath::Native(path) => fs::metadata(path).map(FileMetadata::from),
195193
}
196194
}
197195
}
198196
}
199197

200-
tokio::fs::metadata(path).await.map(FileMetadata::from)
198+
fs::metadata(path).map(FileMetadata::from)
201199
}
202200

203201
async fn symlink_metadata(&self, path: &Path) -> io::Result<FileMetadata> {
204-
tokio::fs::symlink_metadata(path)
205-
.await
206-
.map(FileMetadata::from)
202+
fs::symlink_metadata(path).map(FileMetadata::from)
207203
}
208204

209205
async fn canonicalize(&self, path: &Path) -> io::Result<PathBuf> {

0 commit comments

Comments
 (0)