mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-21 04:58:12 +08:00
Add comment to STORAGE_SIZE and simplify it (#223)
* Add comment to STORAGE_SIZE and simplify it * Modify comment Co-authored-by: RustyNixieTube <RustyNixieTube@users.noreply.github.com>
This commit is contained in:
co-authored by
RustyNixieTube
parent
4c10afe4a4
commit
84fef8a87f
@@ -2,7 +2,9 @@ pub const NUMBER_OF_KEYS: usize = Key::NumKeys as usize;
|
|||||||
// Edit this to specify the storage type used
|
// Edit this to specify the storage type used
|
||||||
// TODO: Increase size of type
|
// TODO: Increase size of type
|
||||||
pub type StorageType = u128;
|
pub type StorageType = u128;
|
||||||
const STORAGE_SIZE: u32 = std::mem::size_of::<usize>() as u32 * 8 + 2 - std::mem::size_of::<StorageType>().leading_zeros();
|
|
||||||
|
// base 2 logarithm of the storage type used to represents how many bits you need to fully address every bit in that storage type
|
||||||
|
const STORAGE_SIZE: u32 = (std::mem::size_of::<StorageType>() * 8).trailing_zeros();
|
||||||
const STORAGE_SIZE_BITS: usize = 1 << STORAGE_SIZE;
|
const STORAGE_SIZE_BITS: usize = 1 << STORAGE_SIZE;
|
||||||
const KEY_MASK_STORAGE_LENGTH: usize = (NUMBER_OF_KEYS + STORAGE_SIZE_BITS - 1) >> STORAGE_SIZE;
|
const KEY_MASK_STORAGE_LENGTH: usize = (NUMBER_OF_KEYS + STORAGE_SIZE_BITS - 1) >> STORAGE_SIZE;
|
||||||
pub type KeyStates = BitVector<KEY_MASK_STORAGE_LENGTH>;
|
pub type KeyStates = BitVector<KEY_MASK_STORAGE_LENGTH>;
|
||||||
|
|||||||
Reference in New Issue
Block a user