Use HashMap instead of BTreeMap

This reduces the file size from 87KiB to 79KiB.
This commit is contained in:
bjorn3
2024-03-10 14:39:29 +01:00
parent ba7eea3043
commit 626a5af3a4
3 changed files with 14 additions and 3 deletions
Generated
+7
View File
@@ -18,6 +18,7 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
name = "bootstrap"
version = "0.0.0"
dependencies = [
"hashbrown",
"linked_list_allocator",
"redox-exec",
"redox-initfs",
@@ -35,6 +36,12 @@ dependencies = [
"scroll",
]
[[package]]
name = "hashbrown"
version = "0.14.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604"
[[package]]
name = "linked_list_allocator"
version = "0.10.5"
+1
View File
@@ -10,6 +10,7 @@ name = "bootstrap"
crate-type = ["staticlib"]
[dependencies]
hashbrown = { version = "0.14", default-features = false, features = ["inline-more"] }
linked_list_allocator = "0.10"
redox-initfs = { git = "https://gitlab.redox-os.org/redox-os/redox-initfs.git", features = ["kernel"], default-features = false }
redox-exec = { git = "https://gitlab.redox-os.org/redox-os/relibc.git" }
+6 -3
View File
@@ -1,9 +1,11 @@
use core::convert::TryFrom;
#[allow(deprecated)]
use core::hash::{BuildHasherDefault, SipHasher};
use core::str;
use alloc::collections::BTreeMap;
use alloc::string::String;
use hashbrown::HashMap;
use redox_initfs::{InitFs, InodeStruct, Inode, InodeDir, InodeKind, types::Timespec};
use syscall::data::{Packet, Stat};
@@ -19,14 +21,15 @@ struct Handle {
filename: String,
}
pub struct InitFsScheme {
handles: BTreeMap<usize, Handle>,
#[allow(deprecated)]
handles: HashMap<usize, Handle, BuildHasherDefault<SipHasher>>,
next_id: usize,
fs: InitFs<'static>,
}
impl InitFsScheme {
pub fn new(bytes: &'static [u8]) -> Self {
Self {
handles: BTreeMap::new(),
handles: HashMap::default(),
next_id: 0,
fs: InitFs::new(bytes).expect("failed to parse initfs"),
}