You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by pivovarit <gi...@git.apache.org> on 2016/02/29 20:14:39 UTC
[GitHub] commons-lang pull request: General cleanup
GitHub user pivovarit opened a pull request:
https://github.com/apache/commons-lang/pull/127
General cleanup
I removed some of the unnecessary code constructs that were driving me mad for some time
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/pivovarit/commons-lang refactor
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/commons-lang/pull/127.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #127
----
----
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] commons-lang pull request: General cleanup
Posted by pivovarit <gi...@git.apache.org>.
Github user pivovarit commented on the pull request:
https://github.com/apache/commons-lang/pull/127#issuecomment-190746576
@garydgregory so I guess this should be fine :)
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] commons-lang pull request: General cleanup
Posted by garydgregory <gi...@git.apache.org>.
Github user garydgregory commented on the pull request:
https://github.com/apache/commons-lang/pull/127#issuecomment-209622299
Final methods is a bigger discussion than what this ticket suggests. It's NOT a code style clean up.
For a general discussion on final, but not specifically of final methods, please see https://garygregory.wordpress.com/2013/01/26/the-final-kiss-in-java/
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] commons-lang pull request: General cleanup
Posted by pivovarit <gi...@git.apache.org>.
Github user pivovarit commented on the pull request:
https://github.com/apache/commons-lang/pull/127#issuecomment-190350478
Well, sure :)
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] commons-lang pull request: General cleanup
Posted by garydgregory <gi...@git.apache.org>.
Github user garydgregory commented on the pull request:
https://github.com/apache/commons-lang/pull/127#issuecomment-191189556
Ok, I'll look tomorrow. In the meantime, can you provide a diff file for all of this?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] commons-lang pull request: General cleanup
Posted by markt-asf <gi...@git.apache.org>.
Github user markt-asf commented on the pull request:
https://github.com/apache/commons-lang/pull/127#issuecomment-191194026
Just add .diff to the end of the pull request URL
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] commons-lang pull request: General cleanup
Posted by garydgregory <gi...@git.apache.org>.
Github user garydgregory commented on the pull request:
https://github.com/apache/commons-lang/pull/127#issuecomment-190406183
I like to look at patch files, which ever way produced. ;-)
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] commons-lang pull request: General cleanup
Posted by pivovarit <gi...@git.apache.org>.
Github user pivovarit commented on the pull request:
https://github.com/apache/commons-lang/pull/127#issuecomment-191133116
@garydgregory well, I did not realize stuff like this matter in practice. I will have done this by tomorrow
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] commons-lang pull request: General cleanup
Posted by pivovarit <gi...@git.apache.org>.
Github user pivovarit closed the pull request at:
https://github.com/apache/commons-lang/pull/127
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] commons-lang pull request: General cleanup
Posted by pivovarit <gi...@git.apache.org>.
Github user pivovarit commented on the pull request:
https://github.com/apache/commons-lang/pull/127#issuecomment-207040689
Are you guys planning on doing something with it or can I close it?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] commons-lang pull request: General cleanup
Posted by pivovarit <gi...@git.apache.org>.
Github user pivovarit commented on the pull request:
https://github.com/apache/commons-lang/pull/127#issuecomment-191180267
@garydgregory PR updated. I thought that those manual iterations are just left-overs from pre-java1.5 era ;)
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] commons-lang pull request: General cleanup
Posted by garydgregory <gi...@git.apache.org>.
Github user garydgregory commented on the pull request:
https://github.com/apache/commons-lang/pull/127#issuecomment-209620015
@pivovarit:
One more thing: Please do not remove 'final' from anything. Send me another diff and I'll review again.
Thank you,
Gary
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] commons-lang pull request: General cleanup
Posted by pivovarit <gi...@git.apache.org>.
Github user pivovarit commented on the pull request:
https://github.com/apache/commons-lang/pull/127#issuecomment-209624730
@garydgregory I am aware of the importance of the `final` keyword in the context your blogpost refers to, but this is something different. Static methods are implicitly final. Adding `final` keyword will only prevent those methods from being hidden in subclasses. Is this what you want to achieve?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] commons-lang pull request: General cleanup
Posted by pivovarit <gi...@git.apache.org>.
Github user pivovarit commented on the pull request:
https://github.com/apache/commons-lang/pull/127#issuecomment-190350730
I will prepare another PR in order to avoid unnecessary commit, ok? Or is this fine?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] commons-lang pull request: General cleanup
Posted by garydgregory <gi...@git.apache.org>.
Github user garydgregory commented on the pull request:
https://github.com/apache/commons-lang/pull/127#issuecomment-209628290
It is what it is for whatever reason the original author intended, that person must have thought it important for subclasses to NOT be able to hide the methods. The class itself should probably be final like any utility class, but we cannot change that in a minor release since it would break BC.
To cut to the chase: I am OK with apply the patch if it does not include the 'final' changes.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] commons-lang pull request: General cleanup
Posted by pivovarit <gi...@git.apache.org>.
Github user pivovarit commented on the pull request:
https://github.com/apache/commons-lang/pull/127#issuecomment-191236251
https://patch-diff.githubusercontent.com/raw/apache/commons-lang/pull/127.diff
Wow, it works indeed. Thanks @markt-asf
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] commons-lang pull request: General cleanup
Posted by garydgregory <gi...@git.apache.org>.
Github user garydgregory commented on the pull request:
https://github.com/apache/commons-lang/pull/127#issuecomment-190350273
Hello,
Thank you for your interest in Apache Commons Lang.
Changes like this are not clean ups because it will cause an unboxing compiler warning.
@@ -465,7 +465,7 @@ public static int toInteger(final Boolean bool, final int trueValue, final int f
if (bool == null) {
return nullValue;
}
- return bool.booleanValue() ? trueValue : falseValue;
+ return bool ? trueValue : falseValue;
}
Would you be willing to update your patch?
Thank you!
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] commons-lang pull request: General cleanup
Posted by garydgregory <gi...@git.apache.org>.
Github user garydgregory commented on the pull request:
https://github.com/apache/commons-lang/pull/127#issuecomment-191131937
Sadly, this kind of change is not a "Good Thing":
@@ -7266,14 +7245,14 @@ public static int indexOfDifference(final CharSequence... css) {
// find the min and max string lengths; this avoids checking to make
// sure we are not exceeding the length of the string each time through
// the bottom loop.
- for (int i = 0; i < arrayLen; i++) {
- if (css[i] == null) {
+ for (CharSequence cs : css) {
+ if (cs == null) {
anyStringNull = true;
shortestStrLen = 0;
} else {
allStringsNull = false;
- shortestStrLen = Math.min(css[i].length(), shortestStrLen);
- longestStrLen = Math.max(css[i].length(), longestStrLen);
+ shortestStrLen = Math.min(cs.length(), shortestStrLen);
+ longestStrLen = Math.max(cs.length(), longestStrLen);
}
}
That is because the compiler converts use an Iterator to traverse an array with a for-each loop which is slower than traversing it with index access. Rule of thumb: don't use for-each over an array when performance matters. In low-level libraries like Commons, performance usually matters.
Please review your patch and remove such changes.
Thank you!
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] commons-lang pull request: General cleanup
Posted by pivovarit <gi...@git.apache.org>.
Github user pivovarit commented on the pull request:
https://github.com/apache/commons-lang/pull/127#issuecomment-209621362
@garydgregory Why is it important to maintain "finality" of static methods?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] commons-lang pull request: General cleanup
Posted by pivovarit <gi...@git.apache.org>.
Github user pivovarit commented on the pull request:
https://github.com/apache/commons-lang/pull/127#issuecomment-209633976
@garydgregory consider it done
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---