use more efficient hash function

This commit is contained in:
Corwin 2022-02-15 21:30:34 +00:00
parent 9095daebd8
commit da9a15402e
2 changed files with 7 additions and 4 deletions

View file

@ -28,6 +28,7 @@ agb_fixnum = { version = "0.1.0", path = "../agb-fixnum" }
bare-metal = "1.0" bare-metal = "1.0"
hashbrown = "0.12.0" hashbrown = "0.12.0"
modular-bitfield = "0.11.2" modular-bitfield = "0.11.2"
rustc-hash = { version = "1.0", default-features = false }
[package.metadata.docs.rs] [package.metadata.docs.rs]
default-target = "thumbv6m-none-eabi" default-target = "thumbv6m-none-eabi"

View file

@ -1,9 +1,11 @@
use alloc::vec::Vec; use alloc::vec::Vec;
use core::alloc::Layout; use core::alloc::Layout;
use core::cell::RefCell; use core::cell::RefCell;
use core::hash::BuildHasherDefault;
use core::ptr::NonNull; use core::ptr::NonNull;
use modular_bitfield::prelude::{B10, B2, B3, B4, B5, B8, B9}; use modular_bitfield::prelude::{B10, B2, B3, B4, B5, B8, B9};
use modular_bitfield::{bitfield, BitfieldSpecifier}; use modular_bitfield::{bitfield, BitfieldSpecifier};
use rustc_hash::FxHasher;
use hashbrown::{hash_map::Entry, HashMap}; use hashbrown::{hash_map::Entry, HashMap};
@ -141,8 +143,8 @@ pub struct Object<'a, 'b> {
} }
struct SpriteControllerInner { struct SpriteControllerInner {
palette: HashMap<PaletteId, Storage>, palette: HashMap<PaletteId, Storage, BuildHasherDefault<FxHasher>>,
sprite: HashMap<SpriteId, Storage>, sprite: HashMap<SpriteId, Storage, BuildHasherDefault<FxHasher>>,
} }
pub struct SpriteController { pub struct SpriteController {
@ -378,8 +380,8 @@ impl SpriteController {
impl SpriteControllerInner { impl SpriteControllerInner {
fn new() -> Self { fn new() -> Self {
Self { Self {
palette: HashMap::new(), palette: HashMap::default(),
sprite: HashMap::new(), sprite: HashMap::default(),
} }
} }
fn get_palette(&mut self, palette: &'static Palette16) -> Option<u16> { fn get_palette(&mut self, palette: &'static Palette16) -> Option<u16> {