[PATCH] Optimize HttpVersion comparison

From: Alex Rousskov <rousskov_at_measurement-factory.com>
Date: Mon, 23 Aug 2010 17:52:47 -0600

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?

-------- proposed commit msg ------------
Simplified HttpVersion initialization and comparison to help compiler
inline them.

GCC defines "major()" and "minor()" macros which conflict with
HttpVersion member initializations (at least). Undefine those macros if
they are present.
----------------------------------------

Thank you,

Alex.

Received on Mon Aug 23 2010 - 23:52:50 MDT

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