hyperium/hyper — pull request #84 by cybergeek94 (2014-10-16 09:32:42+00:00)
Title: Fix and cleanup HTTP Method Parsing

HTTP method parsing was failing, so I rewrote it because it was easier than debugging. All tests pass, the method is a lot shorter and cleaner.

I realized that the method was trying to avoid heap allocations, so my solution does too. Additionally, it avoids reallocating the extension string buffer.

To keep the on-stack buffer small, I limited the extension-method parsing to 16 characters. Somewhat arbitrary, but it should align well on most machines. I hope no one comes up with an HTTP method name longer than that, but if they do, I noted it in the doc so it's not a silent *gotcha*. It can always be updated later.

Don't have a before for comparison, but...

test http::tests::bench_read_method ... bench: 134 ns/iter (+/- 3) = 59 MB/s

*Me gusta*.