You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by Jandalf <js...@apache.org> on 2003/04/27 03:24:22 UTC

[Patch] HttpStatus optimization

Hey Guys,

I did a little optimization on the HttpStatus class.  The old class was 
using a hashtable to map the status codes (integers) to reason phrases 
(strings).  It is unnecessary  to convert the codes to Integer objects 
to use as a key in the hashtable since the status codes map nicely to a 
lookup table.  It was creating a lot of needless objects and was wasting 
space in memory.

Lookups are more than twice as fast now, the memory footprint is 
smaller, and  the static initialization is much faster.  The table size 
needs to be updated if a new status code is added, but it is all in the 
same file and the programmer would be notified on the first test run if 
they neglected it so its a no-brainer.  I took out the logging statement 
as well: there is no reason to log in this class.

This is not commonly used code anyway, I was just scratching an itch. 
 What it really needs is internationalization.

Jandalf.



Re: [Patch] HttpStatus optimization

Posted by Oleg Kalnichevski <o....@dplanet.ch>.
Jandalf,
The patch did not get through. I am afraid attachments get discarded
again.

Cheers

Oleg


On Sun, 2003-04-27 at 03:24, Jandalf wrote:
> Hey Guys,
> 
> I did a little optimization on the HttpStatus class.  The old class was 
> using a hashtable to map the status codes (integers) to reason phrases 
> (strings).  It is unnecessary  to convert the codes to Integer objects 
> to use as a key in the hashtable since the status codes map nicely to a 
> lookup table.  It was creating a lot of needless objects and was wasting 
> space in memory.
> 
> Lookups are more than twice as fast now, the memory footprint is 
> smaller, and  the static initialization is much faster.  The table size 
> needs to be updated if a new status code is added, but it is all in the 
> same file and the programmer would be notified on the first test run if 
> they neglected it so its a no-brainer.  I took out the logging statement 
> as well: there is no reason to log in this class.
> 
> This is not commonly used code anyway, I was just scratching an itch. 
>  What it really needs is internationalization.
> 
> Jandalf.
> 
> 
> 
> 
> ______________________________________________________________________
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-httpclient-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-httpclient-dev-help@jakarta.apache.org