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 [email protected] or file a JIRA ticket
with INFRA.
---