You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Sebb (JIRA)" <ji...@apache.org> on 2012/05/29 20:19:23 UTC
[jira] [Created] (LANG-804) Redundant check for zero in
HashCodeBuilder ctor
Sebb created LANG-804:
-------------------------
Summary: Redundant check for zero in HashCodeBuilder ctor
Key: LANG-804
URL: https://issues.apache.org/jira/browse/LANG-804
Project: Commons Lang
Issue Type: Improvement
Reporter: Sebb
Priority: Minor
The HashCodeBuilder(int, int) ctor checks both parameters for zero, as well as checking for an odd number.
Zero is never odd, so the zero check could be eliminated.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (LANG-804) Redundant check for zero in
HashCodeBuilder ctor
Posted by "Sebb (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/LANG-804?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13286149#comment-13286149 ]
Sebb commented on LANG-804:
---------------------------
Huh? 0 % 2 does not result in / 0 error in the Java compilers I have encountered.
The == 0 checks are redundant, and can just be removed. No other change is needed.
The only reason for keeping them would be to distinguish 0 as a different kind of non-odd number, which seems unnecessary. Otherwise we are saying something like:
"You must use an odd number, and by the way zero is invalid".
> Redundant check for zero in HashCodeBuilder ctor
> ------------------------------------------------
>
> Key: LANG-804
> URL: https://issues.apache.org/jira/browse/LANG-804
> Project: Commons Lang
> Issue Type: Improvement
> Reporter: Sebb
> Priority: Minor
>
> The HashCodeBuilder(int, int) ctor checks both parameters for zero, as well as checking for an odd number.
> Zero is never odd, so the zero check could be eliminated.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (LANG-804) Redundant check for zero in
HashCodeBuilder ctor
Posted by "Gary D. Gregory (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/LANG-804?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13285330#comment-13285330 ]
Gary D. Gregory commented on LANG-804:
--------------------------------------
If you remove the == 0 checks, you'd get a / 0 error on 0 input on the % 2 checks. The current code is pretty simple and straightforward. What would be an alt impl?
> Redundant check for zero in HashCodeBuilder ctor
> ------------------------------------------------
>
> Key: LANG-804
> URL: https://issues.apache.org/jira/browse/LANG-804
> Project: Commons Lang
> Issue Type: Improvement
> Reporter: Sebb
> Priority: Minor
>
> The HashCodeBuilder(int, int) ctor checks both parameters for zero, as well as checking for an odd number.
> Zero is never odd, so the zero check could be eliminated.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Updated] (LANG-804) Redundant check for zero in
HashCodeBuilder ctor
Posted by "Henri Yandell (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/LANG-804?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Henri Yandell updated LANG-804:
-------------------------------
Component/s: lang.builder.*
> Redundant check for zero in HashCodeBuilder ctor
> ------------------------------------------------
>
> Key: LANG-804
> URL: https://issues.apache.org/jira/browse/LANG-804
> Project: Commons Lang
> Issue Type: Improvement
> Components: lang.builder.*
> Reporter: Sebb
> Priority: Minor
>
> The HashCodeBuilder(int, int) ctor checks both parameters for zero, as well as checking for an odd number.
> Zero is never odd, so the zero check could be eliminated.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (LANG-804) Redundant check for zero in
HashCodeBuilder ctor
Posted by "Sebb (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/LANG-804?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13466196#comment-13466196 ]
Sebb commented on LANG-804:
---------------------------
More to the point, perhaps the ctor should check for positive numbers.
Does it make sense for the user to provide negative numbers?
> Redundant check for zero in HashCodeBuilder ctor
> ------------------------------------------------
>
> Key: LANG-804
> URL: https://issues.apache.org/jira/browse/LANG-804
> Project: Commons Lang
> Issue Type: Improvement
> Components: lang.builder.*
> Reporter: Sebb
> Priority: Minor
>
> The HashCodeBuilder(int, int) ctor checks both parameters for zero, as well as checking for an odd number.
> Zero is never odd, so the zero check could be eliminated.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira