Re: JSON headers

On 2016/07/11 14:55, Poul-Henning Kamp wrote:
> --------
> In message <1468211839.6746.67.camel@warmcat.com>, Andy Green writes:
>
>> Actually it'd be nice, and efficient, if we could assemble one header
>> payload in the library, pass it up to the application to copy or act
>> on, and then reuse the buffer, as we go through the incoming, possibly
>> fragmented, header content.
>
> Exactly.
>
> You also avoid the O(N^2) search operation to see if split headers
> happened in the first place.

There are many well-known data structures that avoid O(n^2).

[I personally might try something like gperf (perfect hashing, see 
https://savannah.gnu.org/projects/gperf/) on a wide collection of 
well-known headers, which would make search for these headers O(1), and 
overall O(n) for n headers. Linear search (which leads to O(n^2) for a 
series of headers) could still be used on less well known stuff.]

Regards,   Martin.

Received on Monday, 11 July 2016 10:33:12 UTC