14 Commits

Author SHA1 Message Date
Sean McArthur 45ff933127 Convert header::name to use MaybeUninit (#555)
Co-authored-by: Steven Bosnick <sbosnick@sympatico.ca>
2022-06-06 14:08:18 -07:00
Jed Denlea 49d19ff8a4 Make HeaderName::from_static const (#499)
... plus some clean-up.

It was only after I came up with the scheme using
`const fn from_bytes(&[u8]) -> Option<StandardHeader>`
that I noticed the debug+wasm32-wasi version of `parse_hdr`, which had
something very similar.

While cleaning up that function, I realized it still would still panic
if an attempted name was too long, which had been fixed for all other
targets and profiles in #433.  Then, I thought it would be worth seeing
if the use of `eq!` in the primary version of `parse_hdr` still made any
difference.

And, it would not appear so. At least not on x86_64, nor wasm32-wasi run
via wasmtime.  I've run the benchmarks a number of times now, and it
seems the only significant performance change anywhere is actually that
of `HeaderName::from_static` itself, which now seems to run in about 2/3
the time on average.

Unfortunately, `const fn` still cannot `panic!`, but I've followed the
lead from `HeaderValue::from_static`.  While that version required 1.46,
this new function requires 1.49.  That is almost 8 months old, so
hopefully this isn't too controversial!
2022-04-16 08:40:20 -07:00
Ilya Averyanov 54cf8785ab Added benchmarks for parsing Method (#464) 2021-01-25 15:19:30 -08:00
Sean McArthur ed4dc57067 Add from_maybe_shared constructors
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`
2019-12-02 13:12:38 -08:00
David Barsky 8158916d23 Upgrade to 2018 Edition (#331)
* 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
2019-11-26 12:08:28 -08:00
Matthew Sherborne 21bff29f5b Added benchmarks for parsing header field names 2019-07-26 10:33:41 -07:00
Josh Leeb-du Toit 1cc157eaeb Export http::header::HeaderValue as http::HeaderValue (#222) 2019-06-26 13:11:05 -07:00
Sean McArthur 0922a498f8 add Uri parsing benchmarks 2018-09-10 12:57:52 -07:00
Igor Gnatenko 341e4ce545 deps: update ordermap to 0.4 (#185) 2018-03-10 12:48:06 -08:00
Sean McArthur 57766e8d18 fix benches, get benches compiled on nightly ci 2017-08-19 16:41:38 -07:00
Sean McArthur ef9bdaf459 add HeaderValue::from_shared_unchecked 2017-08-04 17:19:58 -07:00
Carl Lerche e185f77bde Fix some lint warnings in benchmarks 2017-05-05 14:28:59 -07:00
Carl Lerche 01606b1f57 Simplify HeaderMap implementation
The previous implementation of `FastHasher`, while fast, resulted in a
high number of collisions. The fast hash function has been switched to
FNV. After making the switch, benchmarks showed that using static hash
values for standard HTTP headers is actually slower than hashing them on
demand with FNV. This is because hashing standard headers only requires
hashing the enum discriminant. Also, benchmarks show that using a
sequential scan map for small header maps isn't really worth it either.
2017-05-01 12:48:11 -07:00
Carl Lerche cc0c2a04b9 Initial header implementation (#13)
This PR provides an initial pass at a `header` module. This includes a `HeaderName` and `HeaderMap` implementation.
2017-04-26 16:40:45 -07:00