Skip to content

refactor(headers): Improve docs, fix nits, make formatting faster #503

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

Merged
merged 2 commits into from
May 4, 2015
Merged

Conversation

pyfisch
Copy link
Contributor

@pyfisch pyfisch commented May 3, 2015

src/header/parsing.rs now uses unsafe get_unchecked() again, I don't
know why it was removed.

Review on Reviewable

pyfisch added 2 commits May 3, 2015 13:56
src/header/parsing.rs now uses unsafe get_unchecked() again, I don't
know why it was removed.
@@ -9,7 +9,7 @@ pub fn from_one_raw_str<T: str::FromStr>(raw: &[Vec<u8>]) -> Option<T> {
return None;
}
// we JUST checked that raw.len() == 1, so raw[0] WILL exist.
if let Ok(s) = str::from_utf8(&raw[0][..]) {
if let Ok(s) = str::from_utf8(& unsafe { raw.get_unchecked(0) }[..]) {
Copy link
Contributor

Choose a reason for hiding this comment

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

LLVM almost certainly elides the bounds check here anyway. I'd personally rather have less unsafe. I doubt this has a noticeable impact on perf, but I'd be thrilled to be proven wrong.

@seanmonstar
Copy link
Member

src/header/parsing.rs, line 12 [r1] (raw file):
Either way seems fine to me. Or rather, if the "almost certainly" is in fact "absolutely always", then cool. Otherwise, we've done the check above, and a comment reminding anyone about the invariant, so the unsafe looks safe to me as well.



Comments from the review on Reviewable.io

@seanmonstar
Copy link
Member

Reviewed files:

  • src/header/common/accept.rs @ r1
  • src/header/common/access_control_allow_headers.rs @ r1
  • src/header/common/access_control_allow_methods.rs @ r1
  • src/header/common/access_control_max_age.rs @ r1
  • src/header/common/access_control_request_headers.rs @ r1
  • src/header/common/access_control_request_method.rs @ r1
  • src/header/common/allow.rs @ r1
  • src/header/common/authorization.rs @ r1
  • src/header/common/cache_control.rs @ r1
  • src/header/common/connection.rs @ r1
  • src/header/common/content_type.rs @ r1
  • src/header/common/cookie.rs @ r1
  • src/header/common/etag.rs @ r1
  • src/header/common/host.rs @ r1
  • src/header/common/if_range.rs @ r1
  • src/header/common/last_modified.rs @ r1
  • src/header/common/mod.rs @ r1
  • src/header/common/pragma.rs @ r1
  • src/header/common/set_cookie.rs @ r1
  • src/header/internals/item.rs @ r1
  • src/header/mod.rs @ r1
  • src/header/parsing.rs @ r1
  • src/header/shared/charset.rs @ r1
  • src/header/shared/encoding.rs @ r1
  • src/header/shared/entity.rs @ r1
  • src/header/shared/language.rs @ r1

Comments from the review on Reviewable.io

@seanmonstar
Copy link
Member

Hrm, seems reviewable is noisier than I was hoping. Oh well, don't worry about it. Just playing with toys, and this was a larger PR, so seemed opportune.

seanmonstar added a commit that referenced this pull request May 4, 2015
refactor(headers): Improve docs, fix nits, make formatting faster
@seanmonstar seanmonstar merged commit c238890 into hyperium:master May 4, 2015
@pyfisch pyfisch deleted the nice2 branch May 16, 2015 10:53
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.

3 participants