Re: [PATCH] Optimize HttpVersion comparison

From: Kinkie <gkinkie_at_gmail.com>
Date: Tue, 24 Aug 2010 02:22:22 +0200

On Tue, Aug 24, 2010 at 1:52 AM, Alex Rousskov
<rousskov_at_measurement-factory.com> wrote:
> It is easy to get HTTP version comparison wrong. I have added a few
> comparison operators. To be efficient, they need to be inlined by the
> compiler so that the following expression does not have to cause
> HttpVersion(1,0) creation and destruction:
>
>    if (request->http_ver <= HttpVersion(1, 0))
>
> I tried to simplify the constructors and the quality comparison operator to
> increase our chances that they will be inlined. Unfortunately, I ran into a
> GCC "feature" which probably explains why we have not written the
> HttpVersion constructor correctly before.
>
> I added a workaround. Should those #undef lines be moved to some
> compatibility file? If yes, which one?

Can't we just name our data fields Major and Minor?
Also, would adding the inline keyword hint the compiler about our
wishes? I guess it wouldn't hurt (it would also probably not help
either, but still..)
Apart from that, +1.

-- 
    /kinkie
Received on Tue Aug 24 2010 - 00:22:29 MDT

This archive was generated by hypermail 2.2.0 : Tue Aug 24 2010 - 12:00:05 MDT