Wireshark-dev: Re: [Wireshark-dev] Small performance improvements to packet-http.c
Attached please find an updated version of the patch (diff'ed against SVN 23387). It removes (as discussed below) the redundant check for request/reply and also changes some printf("%s", string) -> printf(string).
I'd be happy to get comments on it, especially if it breaks something.
It would be great if it could make its way to 0.99.7, but I'll understand if it'll misses it.
TIA,
Y.
On Nov 5, 2007 9:15 AM, Kaul <
mykaul@xxxxxxxxx> wrote:
Somewhat inspired by the performance improvements to tvbuff, I've made some small performance improvements to packet-http.c:
1. In the most common cases 'GET ', 'POST', 'HTTP' - compare them against the 32bit value of those strings, instead of strncmp(). I reckon in most cases it'll be used, and there won't be need for longer comparison paths.
2. Changed the order of the cases in some switch() statements, to make the common cases first.
3. Changed a look up in an array to have the strings length statically stored in the array, instead of dynamically strlen()'ed every time.
I'm sure there's more room for improvement (I need to fix the fact it goes over the first line of request/reply needlessly twice, trying to figure out if it's a request or response, again), but that's a start - I wanted to get feedback that I didn't break anything (as I suspect I might have, especially with segmented or fragmented requests).
Comments are welcome,
Y.
Attachment:
packet-http.c.diff
Description: Binary data