Use Boolean.valueOf(b) instead of new Boolean(b)
------------------------------------------------
Key: IBATIS-509
URL: https://issues.apache.org/jira/browse/IBATIS-509
Project: iBatis for Java
Issue Type: Improvement
Components: SQL Maps
Affects Versions: 2.3.2
Reporter: Derek Alexander
A performance improvement could be realised by replacing "new Boolean(b)" with
"Boolean.valueOf(b)" in BooleanTypeHandler.
>From the JDK API:
public static Boolean valueOf(boolean b)
Returns a Boolean instance representing the specified boolean value. If the
specified boolean value is true, this method returns Boolean.TRUE; if it is
false, this method returns Boolean.FALSE. If a new Boolean instance is not
required, this method should generally be used in preference to the constructor
Boolean(boolean), as this method is likely to to yield significantly better
space and time performance. (Since: 1.4)
I can't think of a good reason why a new Boolean instance should be required
from BooleanTypeHandler (rather than one of the two static instances mentioed
above).
NOTE: Above method is since JDK 1.4 only, couldn't find details of minimum JVM
targetted. If it is <1.4 you can always use "(b) ? Boolean.TRUE :
Boolean.FALSE" instead.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.