Re:Lwan: Experimental, scalable, high performance HTTP server
by Retric on Sunday October 12, 2014 @06:29PM
(#8446809)
Assuming your reading this from a buffer and most of the time you don't need to count then store an index to the o in hello followed by ignoring space. Then to back and count it only if you need to. Or better yet if whitespace is not need just copy a space but if it's needed then move those bytes to the next stage and don't bother to count them that go around.
[ Parent
| on HN ]
Re:Lwan: Experimental, scalable, high performance HTTP server
by nly on Sunday October 12, 2014 @07:18PM
(#8446893)
... and what happens if your header happens to run off the end of your buffer amongst the spaces that follow 'Hello'? Cookies can be huge, I can construct a header like 'Cookie: x[8000 spaces]y'
Re:Lwan: Experimental, scalable, high performance HTTP server
by Retric on Sunday October 12, 2014 @10:30PM
(#8447273)
This get's into the specifics so you almost need to know the code your dealing with to make a relevant suggestion.
However, the easy option is to default to the slow code path on edge cases which considering it's probably a rare enough it's not important to make fast as long it's bug free. IMO, optimizations are always a balancing act between minimizing the computer's effort and minimizing the coders effort while trying to maintain long term readability. But, you can always keep track of more than one buffer so the option is there.