Message:
A new issue has been created in JIRA.
---------------------------------------------------------------------
View the issue:
http://opensource.atlassian.com/projects/hibernate/secure/ViewIssue.jspa?key=HB-487
Here is an overview of the issue:
---------------------------------------------------------------------
Key: HB-487
Summary: Unecessary object creation in CharBooleanType
Type: Patch
Status: Unassigned
Priority: Trivial
Project: Hibernate2
Components:
core
Versions:
2.1 beta 6
Assignee:
Reporter: Bertrand Renuart
Created: Fri, 21 Nov 2003 1:51 PM
Updated: Fri, 21 Nov 2003 1:51 PM
Description:
Unecessary objects are created when converting the data retrieved from the resultset to a Boolean.
Original code:
--------------
return new Boolean( code.toUpperCase().equals( getTrueString() ) );
Explanation:
------------
- code.toUpperCase() creates a new String - code.equalsIgnoreCase() should be used instead
- new Boolean() creates a new Boolean instance where Boolean.TRUE | FALSE could be used
This would lead to the following code:
if ( code.equalsIgnoreCase(getTrueString())) {
return Boolean.TRUE;
}
else {
return Boolean.FALSE;
}
A bit more efficient ;-)
Note: what should we do if code != getFalseString()? Should we throw an SQLException ?
---------------------------------------------------------------------
JIRA INFORMATION:
This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
If you want more information on JIRA, or have a bug to report see:
http://www.atlassian.com/software/jira
|