Details
-
Improvement
-
Status: Patch Available
-
Minor
-
Resolution: Unresolved
-
None
-
None
-
New
Description
1) Delete unnecessary if statement.
// Line 281 method public void setDimensions(int dimensionCount, int dimensionNumBytes) { ... if (dimensionCount == 0) { if (dimensionNumBytes != 0) { throw new IllegalArgumentException("when dimensionCount is 0, dimensionNumBytes must 0; got " + dimensionNumBytes); } } else if (dimensionNumBytes == 0) { if (dimensionCount != 0) { throw new IllegalArgumentException("when dimensionNumBytes is 0, dimensionCount must 0; got " + dimensionCount); } } ... }
In this code, we can see that the following if statement is unnecessary.
if (dimensionCount != 0) { throw new IllegalArgumentException("when dimensionNumBytes is 0, dimensionCount must 0; got " + dimensionCount); }
Because it is a condition that is already processed in the upper if statement
(if dimensionCount == 0)
So I made the following code.
// Line 281 method public void setDimensions(int dimensionCount, int dimensionNumBytes) { ... if (dimensionCount == 0) { if (dimensionNumBytes != 0) { throw new IllegalArgumentException("when dimensionCount is 0, dimensionNumBytes must 0; got " + dimensionNumBytes); } } else if (dimensionNumBytes == 0) { throw new IllegalArgumentException("when dimensionNumBytes is 0, dimensionCount must 0; got " + dimensionCount); } ... }
2) Simplify if statement
// Line 417 method public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; ... if (storeTermVectors != other.storeTermVectors) return false; if (stored != other.stored) return false; if (tokenized != other.tokenized) return false; return true; }
The final if statement can be simplified.
// Line 417 method public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; ... if (storeTermVectors != other.storeTermVectors) return false; if (stored != other.stored) return false; return tokenized == other.tokenized; }
But I worry that change will hinder readability.
For that reason, if it is not good, I will not reflect it in the patch.