Skip to content

Commit

Permalink
bytewords: use static allocated hash map
Browse files Browse the repository at this point in the history
The hash map is generated at compile time, this is to not allocate at
runtime the HashMap as I'm going to make some PRs to make this crate
no_std friendly.

Signed-off-by: Jean-Pierre De Jesus DIAZ <me@jeandudey.tech>
  • Loading branch information
jeandudey committed Dec 10, 2022
1 parent f820d9b commit 8feb133
Show file tree
Hide file tree
Showing 4 changed files with 610 additions and 534 deletions.
94 changes: 90 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Expand Up @@ -12,10 +12,10 @@ anyhow = "1.0.64"
bitcoin_hashes = "0.11.0"
crc = "3.0.0"
hex = "0.4.3"
once_cell = "1.16.0"
rand_xoshiro = "0.6.0"
serde = "1.0.147"
serde_cbor = { version = "0.11.2", features = ["tags"] }
phf = { version = "0.11.1", features = ["macros"], default-features = false }

[dev-dependencies]
qrcode = { version = "0.12.0", default-features = false }
2 changes: 1 addition & 1 deletion src/bytewords.rs
Expand Up @@ -111,7 +111,7 @@ fn decode_minimal(encoded: &str) -> Result<Vec<u8>, Error> {

fn decode_from_index(
keys: &mut dyn Iterator<Item = &str>,
indexes: &std::collections::HashMap<&'static str, u8>,
indexes: &phf::Map<&'static str, u8>,
) -> Result<Vec<u8>, Error> {
strip_checksum(
&keys
Expand Down

0 comments on commit 8feb133

Please sign in to comment.