Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting started on Huffman tables #441

Merged
merged 2 commits into from
Sep 17, 2019

Conversation

Yoric
Copy link
Collaborator

@Yoric Yoric commented Sep 11, 2019

No description provided.

@Yoric Yoric requested a review from dominiccooney September 11, 2019 11:46
@Yoric Yoric force-pushed the context-0.1-huffman branch 3 times, most recently from 5781f2a to 65b6bd8 Compare September 13, 2019 08:11
@Yoric Yoric force-pushed the context-0.1-huffman branch from 65b6bd8 to 525603e Compare September 13, 2019 09:04
use std::rc::Rc;

/// A newtype for `u8` used to count the length of a key in bits.
#[derive(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Long list. Is there a convenient bag of traits which imply all of these?

Copy link
Collaborator Author

@Yoric Yoric Sep 13, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it's verbose, but I don't know of any such trait.
There used to be something called "int-like", I believe, in another crate, but that crate is now deprecated. I could write a macro, though.

// Convert tree into bit lengths
let root = heap.pop().unwrap(); // We have checked above that there is at least one value.
let mut bit_lengths = Vec::with_capacity(len);
fn aux<T>(bit_lengths: &mut Vec<(T, BitLen)>, depth: u8, node: NodeContent<T>) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be worth putting a FIXME/TODO and an assert here that the length generated is not >20 bits, since this is the earliest you can detect length limits are going to be violated and the code you'll have to change to do limits.

Copy link
Collaborator Author

@Yoric Yoric Sep 13, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought the idea was to not make the 20 bits part of the spec?

Did I misunderstand #440 (comment) ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a mechanism to check that we do not exceed a maximal length.

@Yoric Yoric force-pushed the context-0.1-huffman branch from b2de953 to 8289734 Compare September 13, 2019 09:58
@dominiccooney
Copy link
Member

dominiccooney commented Sep 13, 2019 via email

@Yoric Yoric force-pushed the context-0.1-huffman branch from 8289734 to 0d900c2 Compare September 13, 2019 10:38
Copy link
Member

@dominiccooney dominiccooney left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, one nit inline.

@@ -113,11 +112,20 @@ where
{
/// Compute a `Keys` from a sequence of values.
///
/// Optionally, `max_bit_len` may specify a largest acceptable bit length.
/// If `Keys` may not be computed without exceeding this bit length,
/// fail with `Err(problemantic_bit_length)`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: problematic

@dominiccooney dominiccooney merged commit b6c5727 into binast:master Sep 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants