summary refs log tree commit diff
path: root/ripple/fossil
diff options
context:
space:
mode:
authoredef <edef@unfathomable.blue>2022-05-04 12:37:07 +0000
committeredef <edef@unfathomable.blue>2022-05-04 12:37:07 +0000
commitc7d9e9c09a5cc77092c43eef0780e1e8c39076d0 (patch)
treed607ca55363cc7862ce3039f7fb9a5869cf9dde4 /ripple/fossil
parent9fc107d2540f914b8019876d07f80388f90285c6 (diff)
downloadunf-legacy-c7d9e9c09a5cc77092c43eef0780e1e8c39076d0.tar.zst
ripple/fossil/mount: don't allocate on readdir
Change-Id: I319a2de0da0ff71f0f337e5a17ef199f23254b11
Diffstat (limited to 'ripple/fossil')
-rw-r--r--ripple/fossil/src/bin/mount.rs22
1 files changed, 11 insertions, 11 deletions
diff --git a/ripple/fossil/src/bin/mount.rs b/ripple/fossil/src/bin/mount.rs
index ee46b8e..f1bcdde 100644
--- a/ripple/fossil/src/bin/mount.rs
+++ b/ripple/fossil/src/bin/mount.rs
@@ -388,23 +388,23 @@ impl fuser::Filesystem for Filesystem {
 					}
 				};
 
-				let mut children = vec![
-					(ino, fuser::FileType::Directory, "."),
-					(ino, fuser::FileType::Directory, ".."),
-				];
-
-				for entry in dir.iter() {
+				let children = dir.iter().map(|entry| {
 					let kind = match entry.node() {
 						memtree::Node::Directory(_) => fuser::FileType::Directory,
 						memtree::Node::File(_) => fuser::FileType::RegularFile,
 						memtree::Node::Link { .. } => fuser::FileType::Symlink,
 					};
-					children.push((ino + entry.index as u64 + 1, kind, &entry.name));
-				}
+					(ino + entry.index as u64 + 1, kind, entry.name.as_str())
+				});
+
+				let children = [
+					(ino, fuser::FileType::Directory, "."),
+					(ino, fuser::FileType::Directory, ".."),
+				]
+				.into_iter()
+				.chain(children);
 
-				for (offset, &(ino, kind, name)) in
-					children.iter().enumerate().skip(offset as usize)
-				{
+				for (offset, (ino, kind, name)) in children.enumerate().skip(offset as usize) {
 					if reply.add(ino, (offset + 1) as i64, kind, name) {
 						break;
 					}