-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
small-code-quality-improvements #3
small-code-quality-improvements #3
Conversation
@@ -412,7 +412,7 @@ private boolean isSorted() { | |||
if (array == null) { | |||
return true; | |||
} | |||
final boolean strict = isMinIncluded | isMaxIncluded; | |||
final boolean strict = isMinIncluded || isMaxIncluded; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, if the compiler were generating code verbatim, the use of |
operator would be more efficient than ||
because a bitwise OR
operation is faster than a jump on modern processor. But I guess that in practice, optimization done by the compiler results in the same assembly code in the end.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, that astonished me due to the general known logical vs. bitwise stuff.
However, I've learned something and you're completely right -
http://javarevisited.blogspot.co.at/2015/01/difference-between-bitwsie-and-logical.html
Thank you!
I am going to undo this change.
if (versionGML.compareTo(LegacyNamespaces.VERSION_3_2_1) < 0) { | ||
return FilterVersion.GML31; | ||
} | ||
if (versionGML != null && versionGML.compareTo(LegacyNamespaces.VERSION_3_2_1) < 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason why this condition was keep in two separated if
statement is because we currently check for only one version (GML 3.2.1), but we are likely to add new versions in the future. So the code may become something like:
if (version GML != null) {
if (versionGML.compareTo(VERSION_3_2_1) < 0) do something
if (versionGML.compareTo(VERSION_3_3) >= 0) do something else
etc.
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Going to undo this too.
@@ -310,7 +310,6 @@ public void accept(final long sample) { | |||
public void combine(final Statistics stats) { | |||
ArgumentChecks.ensureNonNull("stats", stats); | |||
|
|||
// "if (a < b)" is equivalent to "if (!isNaN(a) && a < b)". |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why removing the comment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seemed unnecessary.
Therefore I removed it to increase readability.
Going to undo the change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The key element in the comment was the isNaN(a)
part. Not so many developers are aware that (a < b)
and !(a >= b)
are not equivalent when using floating point numbers.
@@ -146,7 +146,6 @@ public WeakHashSet(final Class<E> type) { | |||
@SuppressWarnings("unchecked") | |||
@Workaround(library="JDK", version="1.7") | |||
final Entry[] table = (Entry[]) Array.newInstance(Entry.class, MIN_CAPACITY); | |||
// table = new Entry[size]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just before this comment, they were another comment explaining why we keep this comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missed that comment.
Going to undo.
@@ -464,6 +463,7 @@ public V put(final K key, final V value) throws NullArgumentException { | |||
* | |||
* @since 0.7 | |||
*/ | |||
@Override |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this particular case, this annotation can not be applied on a branch targeting JDK7.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, going to undo.
case 2: tail = parsedNames.get(1); break; | ||
case 1: // fall through | ||
case 0: throw new AssertionError(size); | ||
default: tail = new DefaultScopedName(parsedNames.subList(1, size)); break; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The previous code had a logical ordering from highest value (where default
stands for all values greater than 2) to zero.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I considered it to be a small improvement due to https://sonarcloud.io/organizations/default/rules#rule_key=squid%3ASwitchLastCaseIsDefaultCheck
Going to undo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this switch the default is not for defensing programming, but is a case expected to be run in normal execution (actually most of the time for that switch statement).
@@ -571,6 +571,7 @@ public void logp(final Level level, final String sourceClass, final String sourc | |||
* | |||
* @since 0.5 | |||
*/ | |||
@Override |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In those particular cases, this annotation can not be added on a code targeting JDK7 platform, because this method had been added in JDK8.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Undoing.
git-svn-id: https://svn.apache.org/repos/asf/sis/branches/JDK8@1809637 13f79535-47bb-0310-9956-ffa450edef68
Committed on 1f9c213 |
Okay, just in that minute saw you've already commited the changes you accepted. Shall I push further changes I consider to be improvements? |
Further changes I consider to be improvements general in the SIS project NOT in this pull request. |
If you wish that would nice! But I propose that you do the patch against JDK8 branch instead of trunk. Also when doing tests, I suggest the following:
|
Made small code quality improvements.