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

Stop allocating so much while formatting. #100

Merged
merged 5 commits into from
Jan 15, 2017

Conversation

tomprince
Copy link
Contributor

See #41.

This is a breaking change, as it cleans up the public API by hiding the details of formatting.

Copy link
Member

@untitaker untitaker left a comment

Choose a reason for hiding this comment

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

Nice work, but still I found some nitpicks.

@@ -173,3 +184,21 @@ pub enum FormatText {
pub struct FormatUnit {
pub text: FormatText,
}


#[doc(hidden)]
Copy link
Member

Choose a reason for hiding this comment

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

Not necessary if the entire mod is not public, no?


}

pub fn display_with<'a>(format: &'a Format,
Copy link
Member

Choose a reason for hiding this comment

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

Ideally this would be a method on Format, but I realize that this is not possible due to the wish to constrain the public API.

You could also think about it as a constructor of FormatDisplay but I'm not sure if that's an internal API we want.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I turned it into a method of a private trait. I'm not entirely sure that the trait is appropriately generic, but given that it currently has a single use, I don't think that is a big deal.

Method => fmt.write_fmt(format_args!("{}", req.method)),
URI => fmt.write_fmt(format_args!("{}", req.url)),
Status => match res.status {
Some(status) => fmt.write_fmt(format_args!("{}", status)),
Copy link
Member

Choose a reason for hiding this comment

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

You can replace this with status.fmt I think. Same goes for similar branches.

@tomprince
Copy link
Contributor Author

Updated.

@untitaker untitaker merged commit 5a76b50 into iron:master Jan 15, 2017
@untitaker
Copy link
Member

Thanks!

@untitaker
Copy link
Member

untitaker commented Jan 15, 2017

Oh, feel free to add yourself to the authors array in Cargo.toml though I'm not sure if that's how we're tracking contributors now. Otherwise I'll release a new version ASAP

@tomprince tomprince deleted the stop-allocating branch January 15, 2017 21:56
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