* HeaderMap: Store pos and hash as u16
HeaderMap currently truncates all hashes to 16 bits, and limits its
capacity to 32768 elements. The comments say this is done in order to
store positions and hashes as u16, to improve cache locality. However,
they are currently stored as usize. This patch changes the code to
match the comments.
This does not appear to cause any measurable improvement or regression
in speed in the HeaderMap benchmarks. However, it should at least reduce
the memory footprint of every Headermap.
* Fix overflow check for raw capacity.
The actual maximum capacity is 24578 (i.e. `32768 * 3/4`).
A higher number would cause the raw capacity (i.e. `capacity +
capacity/3` rounded to the next power of 2) to overflow `u16`.
We were for a time allowing warnings on two sections of code due to
continued use of `...` pattern syntax. We had deferred the change to
`..=` syntax so as to support earlier Rust versions.
However, in commit `6059be7a99a264abf9afb8e6b8461413b972e892` we
changed over to `..=` syntax. The `allow(warnings)` attributes and
the related comments are now obsolete, and we remove them in this
commit.
These constructors don't expose the internal `Bytes` type, but instead
will try to downcast the argument to prevent a copy. If the types don't
match up (a user provides an older version of `Bytes`), the value will
just be copied.
Adds:
- `HeaderValue::from_maybe_shared`
- `HeaderValue::from_maybe_shared_unchecked`
- `Uri::from_maybe_shared`
- `Authority::from_maybe_shared`
- `PathAndQuery::from_maybe_shared`
We reserved these extra error types with the goal of possibly returning
the source `Bytes` in the error type, but no one has since need this.
Since the dependency on `bytes` is being made private, it made sense to
remove these otherwise unused error types.
Removes:
- `InvalidUriBytes`
- `InvalidHeaderNameBytes`
- `InvalidHeaderValueBytes`
Since the builders are only 1-time use anyways, it makes more sense to
enforce that through the type system, than to leave behind a panic bomb.
Most code that was just one chain should be un-affected.
* 2018 edition, babey!
* run `cargo fix --edition-idioms`
* yes, we do intend to drop the iterator, thanks rustc!
* cargo fmt
* aggressive min rustc version bump to fix travis
* 1.37 is not out, oops
- Only types that implement `IntoHeaderName` can now be passed to
`entry`, though they still are lazily cloned.
- Adds `HeaderMap::try_entry` that works as before, returning a `Result`
if the key isn't a valid `HeaderName`.
This is a breaking change.
Closes#267
This change fixes an issue where an URI with no scheme, a host
part with a length greater than the max for a scheme, while only
consisting of valid characters for a scheme would fail to parse.
Rather than assuming the string being parsed is meant to contain
a scheme and returning an error if the max length for a scheme is
met, we instead extract the scheme part if it exists and validate
its length.
The trade-off is worse performance in the error case of a scheme
that is too long.