Skip to content

Commit

Permalink
Remove byteorder-dependency (hyperium#392)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaslueg authored and carllerche committed Aug 9, 2019
1 parent 0a9a261 commit 782f1f7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
1 change: 0 additions & 1 deletion Cargo.toml
Expand Up @@ -45,7 +45,6 @@ futures = "0.1"
tokio-io = "0.1.4"
bytes = "0.4.7"
http = "0.1.8"
byteorder = "1.0"
log = "0.4.1"
fnv = "1.0.5"
slab = "0.4.0"
Expand Down
5 changes: 3 additions & 2 deletions src/frame/headers.rs
Expand Up @@ -5,7 +5,6 @@ use crate::hpack;
use http::{uri, HeaderMap, Method, StatusCode, Uri};
use http::header::{self, HeaderName, HeaderValue};

use byteorder::{BigEndian, ByteOrder};
use bytes::{Bytes, BytesMut};
use string::String;

Expand Down Expand Up @@ -563,7 +562,9 @@ impl EncodingHeaderBlock {
let payload_len = (dst.len() - payload_pos) as u64;

// Write the frame length
BigEndian::write_uint(&mut dst[head_pos..head_pos + 3], payload_len, 3);
let payload_len_be = payload_len.to_be_bytes();
assert!(payload_len_be[0..5].iter().all(|b| *b == 0));
(&mut dst[head_pos..head_pos + 3]).copy_from_slice(&payload_len_be[5..]);

if continuation.is_some() {
// There will be continuation frames, so the `is_end_headers` flag
Expand Down
5 changes: 3 additions & 2 deletions src/frame/stream_id.rs
@@ -1,4 +1,3 @@
use byteorder::{BigEndian, ByteOrder};
use std::u32;

/// A stream identifier, as described in [Section 5.1.1] of RFC 7540.
Expand Down Expand Up @@ -29,7 +28,9 @@ impl StreamId {
/// Parse the stream ID
#[inline]
pub fn parse(buf: &[u8]) -> (StreamId, bool) {
let unpacked = BigEndian::read_u32(buf);
let mut ubuf = [0; 4];
ubuf.copy_from_slice(&buf[0..4]);
let unpacked = u32::from_be_bytes(ubuf);
let flag = unpacked & STREAM_ID_MASK == STREAM_ID_MASK;

// Now clear the most significant bit, as that is reserved and MUST be
Expand Down

0 comments on commit 782f1f7

Please sign in to comment.