Thread: Unnessecary use of new Integer(n) in AbstractJdbc2ResultSet

Unnessecary use of new Integer(n) in AbstractJdbc2ResultSet

From
Daniel Migowski
Date:
 Hi,

I am using the postgresql driver 8.3-604-jdbc3, and noticed something strange in my profiling reports:

In Line 2518 of AbstractJdbc2ResultSet, in function findColumnIndex, there is a call to "new Integer(n)", which takes 2% overall time in my app! It should be replaced by "Integer.valueOf(n)", because this doesn't create any new instances on Integer for the usecase found here!

Regards,
Daniel Migowski

Re: Unnessecary use of new Integer(n) in AbstractJdbc2ResultSet

From
Kris Jurka
Date:

On Sat, 23 Apr 2011, Daniel Migowski wrote:

> I am using the postgresql driver 8.3-604-jdbc3, and noticed something
> strange in my profiling reports:
>
> In Line 2518 of AbstractJdbc2ResultSet, in function findColumnIndex, there
> is a call to "new Integer(n)", which takes 2% overall time in my app! It
> should be replaced by "Integer.valueOf(n)", because this doesn't create any
> new instances on Integer for the usecase found here!
>

Integer.valueOf appeared in JDK 1.5 and we currently still support JDK
1.4.  There's been talk of ditching 1.4 support, but that hasn't
officially happened yet and isn't something we'd do for older driver
releases.

Kris Jurka