Enable PMD rule UnnecessaryBoxing and fix violations
This commit is contained in:
parent
dd896347a2
commit
c73a8cebb8
6 changed files with 30 additions and 34 deletions
|
@ -419,7 +419,7 @@ public final class MicroCache2 extends MicroCache {
|
||||||
nlinks++;
|
nlinks++;
|
||||||
|
|
||||||
if (isInternal) {
|
if (isInternal) {
|
||||||
int nodeIdx = idx.intValue();
|
int nodeIdx = idx;
|
||||||
if (dodebug) System.out.println("*** target nodeIdx=" + nodeIdx);
|
if (dodebug) System.out.println("*** target nodeIdx=" + nodeIdx);
|
||||||
if (nodeIdx == n) throw new RuntimeException("ups: self ref?");
|
if (nodeIdx == n) throw new RuntimeException("ups: self ref?");
|
||||||
nodeIdxDiff.encodeSignedValue(nodeIdx - n);
|
nodeIdxDiff.encodeSignedValue(nodeIdx - n);
|
||||||
|
|
|
@ -296,7 +296,7 @@ abstract class OsmPath implements OsmLinkHolder {
|
||||||
// apply a start-direction if appropriate (by faking the origin position)
|
// apply a start-direction if appropriate (by faking the origin position)
|
||||||
if (isStartpoint) {
|
if (isStartpoint) {
|
||||||
if (rc.startDirectionValid) {
|
if (rc.startDirectionValid) {
|
||||||
double dir = rc.startDirection.intValue() * CheapRuler.DEG_TO_RAD;
|
double dir = rc.startDirection * CheapRuler.DEG_TO_RAD;
|
||||||
double[] lonlat2m = CheapRuler.getLonLatToMeterScales((lon0 + lat1) >> 1);
|
double[] lonlat2m = CheapRuler.getLonLatToMeterScales((lon0 + lat1) >> 1);
|
||||||
lon0 = lon1 - (int) (1000. * Math.sin(dir) / lonlat2m[0]);
|
lon0 = lon1 - (int) (1000. * Math.sin(dir) / lonlat2m[0]);
|
||||||
lat0 = lat1 - (int) (1000. * Math.cos(dir) / lonlat2m[1]);
|
lat0 = lat1 - (int) (1000. * Math.cos(dir) / lonlat2m[1]);
|
||||||
|
|
|
@ -246,7 +246,7 @@ public abstract class BExpressionContext implements IByteArrayUnifier {
|
||||||
public int getLookupKey(String name) {
|
public int getLookupKey(String name) {
|
||||||
int res = -1;
|
int res = -1;
|
||||||
try {
|
try {
|
||||||
res = lookupNumbers.get(name).intValue();
|
res = lookupNumbers.get(name);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
|
@ -438,7 +438,7 @@ public abstract class BExpressionContext implements IByteArrayUnifier {
|
||||||
// first count
|
// first count
|
||||||
for (String name : lookupNumbers.keySet()) {
|
for (String name : lookupNumbers.keySet()) {
|
||||||
int cnt = 0;
|
int cnt = 0;
|
||||||
int inum = lookupNumbers.get(name).intValue();
|
int inum = lookupNumbers.get(name);
|
||||||
int[] histo = lookupHistograms.get(inum);
|
int[] histo = lookupHistograms.get(inum);
|
||||||
// if ( histo.length == 500 ) continue;
|
// if ( histo.length == 500 ) continue;
|
||||||
for (int i = 2; i < histo.length; i++) {
|
for (int i = 2; i < histo.length; i++) {
|
||||||
|
@ -451,7 +451,7 @@ public abstract class BExpressionContext implements IByteArrayUnifier {
|
||||||
String key = counts.lastEntry().getKey();
|
String key = counts.lastEntry().getKey();
|
||||||
String name = counts.get(key);
|
String name = counts.get(key);
|
||||||
counts.remove(key);
|
counts.remove(key);
|
||||||
int inum = lookupNumbers.get(name).intValue();
|
int inum = lookupNumbers.get(name);
|
||||||
BExpressionLookupValue[] values = lookupValues.get(inum);
|
BExpressionLookupValue[] values = lookupValues.get(inum);
|
||||||
int[] histo = lookupHistograms.get(inum);
|
int[] histo = lookupHistograms.get(inum);
|
||||||
if (values.length == 1000) continue;
|
if (values.length == 1000) continue;
|
||||||
|
@ -508,7 +508,7 @@ public abstract class BExpressionContext implements IByteArrayUnifier {
|
||||||
|
|
||||||
public String variableName(int idx) {
|
public String variableName(int idx) {
|
||||||
for (Map.Entry<String, Integer> e : variableNumbers.entrySet()) {
|
for (Map.Entry<String, Integer> e : variableNumbers.entrySet()) {
|
||||||
if (e.getValue().intValue() == idx) {
|
if (e.getValue() == idx) {
|
||||||
return e.getKey();
|
return e.getKey();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -545,9 +545,8 @@ public abstract class BExpressionContext implements IByteArrayUnifier {
|
||||||
}
|
}
|
||||||
|
|
||||||
// look for that value
|
// look for that value
|
||||||
int inum = num.intValue();
|
BExpressionLookupValue[] values = lookupValues.get(num);
|
||||||
BExpressionLookupValue[] values = lookupValues.get(inum);
|
int[] histo = lookupHistograms.get(num);
|
||||||
int[] histo = lookupHistograms.get(inum);
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
boolean bFoundAsterix = false;
|
boolean bFoundAsterix = false;
|
||||||
for (; i < values.length; i++) {
|
for (; i < values.length; i++) {
|
||||||
|
@ -559,7 +558,7 @@ public abstract class BExpressionContext implements IByteArrayUnifier {
|
||||||
if (lookupData2 != null) {
|
if (lookupData2 != null) {
|
||||||
// do not create unknown value for external data array,
|
// do not create unknown value for external data array,
|
||||||
// record as 'unknown' instead
|
// record as 'unknown' instead
|
||||||
lookupData2[inum] = 1; // 1 == unknown
|
lookupData2[num] = 1; // 1 == unknown
|
||||||
if (bFoundAsterix) {
|
if (bFoundAsterix) {
|
||||||
// found value for lookup *
|
// found value for lookup *
|
||||||
//System.out.println( "add unknown " + name + " " + value );
|
//System.out.println( "add unknown " + name + " " + value );
|
||||||
|
@ -653,11 +652,11 @@ public abstract class BExpressionContext implements IByteArrayUnifier {
|
||||||
// found negative maxdraft values
|
// found negative maxdraft values
|
||||||
// no negative values
|
// no negative values
|
||||||
// values are float with 2 decimals
|
// values are float with 2 decimals
|
||||||
lookupData2[inum] = 1000 + (int) (Math.abs(Float.parseFloat(value)) * 100f);
|
lookupData2[num] = 1000 + (int) (Math.abs(Float.parseFloat(value)) * 100f);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// ignore errors
|
// ignore errors
|
||||||
System.err.println("error for " + name + " " + org + " trans " + value + " " + e.getMessage());
|
System.err.println("error for " + name + " " + org + " trans " + value + " " + e.getMessage());
|
||||||
lookupData2[inum] = 0;
|
lookupData2[num] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return newValue;
|
return newValue;
|
||||||
|
@ -678,15 +677,15 @@ public abstract class BExpressionContext implements IByteArrayUnifier {
|
||||||
histo = nhisto;
|
histo = nhisto;
|
||||||
newValue = new BExpressionLookupValue(value);
|
newValue = new BExpressionLookupValue(value);
|
||||||
values[i] = newValue;
|
values[i] = newValue;
|
||||||
lookupHistograms.set(inum, histo);
|
lookupHistograms.set(num, histo);
|
||||||
lookupValues.set(inum, values);
|
lookupValues.set(num, values);
|
||||||
}
|
}
|
||||||
|
|
||||||
histo[i]++;
|
histo[i]++;
|
||||||
|
|
||||||
// finally remember the actual data
|
// finally remember the actual data
|
||||||
if (lookupData2 != null) lookupData2[inum] = i;
|
if (lookupData2 != null) lookupData2[num] = i;
|
||||||
else lookupData[inum] = i;
|
else lookupData[num] = i;
|
||||||
return newValue;
|
return newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -701,11 +700,10 @@ public abstract class BExpressionContext implements IByteArrayUnifier {
|
||||||
}
|
}
|
||||||
|
|
||||||
// look for that value
|
// look for that value
|
||||||
int inum = num.intValue();
|
int nvalues = lookupValues.get(num).length;
|
||||||
int nvalues = lookupValues.get(inum).length;
|
|
||||||
if (valueIndex < 0 || valueIndex >= nvalues)
|
if (valueIndex < 0 || valueIndex >= nvalues)
|
||||||
throw new IllegalArgumentException("value index out of range for name " + name + ": " + valueIndex);
|
throw new IllegalArgumentException("value index out of range for name " + name + ": " + valueIndex);
|
||||||
lookupData[inum] = valueIndex;
|
lookupData[num] = valueIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -722,9 +720,8 @@ public abstract class BExpressionContext implements IByteArrayUnifier {
|
||||||
}
|
}
|
||||||
|
|
||||||
// look for that value
|
// look for that value
|
||||||
int inum = num.intValue();
|
int nvalues = lookupValues.get(num).length;
|
||||||
int nvalues = lookupValues.get(inum).length;
|
int oldValueIndex = lookupData[num];
|
||||||
int oldValueIndex = lookupData[inum];
|
|
||||||
if (oldValueIndex > 1 && oldValueIndex < valueIndex) {
|
if (oldValueIndex > 1 && oldValueIndex < valueIndex) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -733,12 +730,12 @@ public abstract class BExpressionContext implements IByteArrayUnifier {
|
||||||
}
|
}
|
||||||
if (valueIndex < 0)
|
if (valueIndex < 0)
|
||||||
throw new IllegalArgumentException("value index out of range for name " + name + ": " + valueIndex);
|
throw new IllegalArgumentException("value index out of range for name " + name + ": " + valueIndex);
|
||||||
lookupData[inum] = valueIndex;
|
lookupData[num] = valueIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getBooleanLookupValue(String name) {
|
public boolean getBooleanLookupValue(String name) {
|
||||||
Integer num = lookupNumbers.get(name);
|
Integer num = lookupNumbers.get(name);
|
||||||
return num != null && lookupData[num.intValue()] == 2;
|
return num != null && lookupData[num] == 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getOutputVariableIndex(String name, boolean mustExist) {
|
public int getOutputVariableIndex(String name, boolean mustExist) {
|
||||||
|
@ -850,7 +847,7 @@ public abstract class BExpressionContext implements IByteArrayUnifier {
|
||||||
public void setVariableValue(String name, float value, boolean create) {
|
public void setVariableValue(String name, float value, boolean create) {
|
||||||
Integer num = variableNumbers.get(name);
|
Integer num = variableNumbers.get(name);
|
||||||
if (num != null) {
|
if (num != null) {
|
||||||
variableData[num.intValue()] = value;
|
variableData[num] = value;
|
||||||
} else if (create) {
|
} else if (create) {
|
||||||
num = getVariableIdx(name, create);
|
num = getVariableIdx(name, create);
|
||||||
float[] readOnlyData = variableData;
|
float[] readOnlyData = variableData;
|
||||||
|
@ -859,13 +856,13 @@ public abstract class BExpressionContext implements IByteArrayUnifier {
|
||||||
for (int i = 0; i < minWriteIdx; i++) {
|
for (int i = 0; i < minWriteIdx; i++) {
|
||||||
variableData[i] = readOnlyData[i];
|
variableData[i] = readOnlyData[i];
|
||||||
}
|
}
|
||||||
variableData[num.intValue()] = value;
|
variableData[num] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getVariableValue(String name, float defaultValue) {
|
public float getVariableValue(String name, float defaultValue) {
|
||||||
Integer num = variableNumbers.get(name);
|
Integer num = variableNumbers.get(name);
|
||||||
return num == null ? defaultValue : getVariableValue(num.intValue());
|
return num == null ? defaultValue : getVariableValue(num);
|
||||||
}
|
}
|
||||||
|
|
||||||
float getVariableValue(int variableIdx) {
|
float getVariableValue(int variableIdx) {
|
||||||
|
@ -883,7 +880,7 @@ public abstract class BExpressionContext implements IByteArrayUnifier {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return num.intValue();
|
return num;
|
||||||
}
|
}
|
||||||
|
|
||||||
int getMinWriteIdx() {
|
int getMinWriteIdx() {
|
||||||
|
@ -901,7 +898,7 @@ public abstract class BExpressionContext implements IByteArrayUnifier {
|
||||||
|
|
||||||
public int getLookupNameIdx(String name) {
|
public int getLookupNameIdx(String name) {
|
||||||
Integer num = lookupNumbers.get(name);
|
Integer num = lookupNumbers.get(name);
|
||||||
return num == null ? -1 : num.intValue();
|
return num == null ? -1 : num;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void markLookupIdxUsed(int idx) {
|
public final void markLookupIdxUsed(int idx) {
|
||||||
|
|
|
@ -15,7 +15,7 @@ public class IpAccessMonitor {
|
||||||
synchronized (sync) {
|
synchronized (sync) {
|
||||||
Long lastTime = ipAccess.get(ip);
|
Long lastTime = ipAccess.get(ip);
|
||||||
ipAccess.put(ip, t);
|
ipAccess.put(ip, t);
|
||||||
return lastTime == null || t - lastTime.longValue() > MAX_IDLE;
|
return lastTime == null || t - lastTime > MAX_IDLE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ public class IpAccessMonitor {
|
||||||
private static void cleanup(long t) {
|
private static void cleanup(long t) {
|
||||||
Map<String, Long> newMap = new HashMap<>(ipAccess.size());
|
Map<String, Long> newMap = new HashMap<>(ipAccess.size());
|
||||||
for (Map.Entry<String, Long> e : ipAccess.entrySet()) {
|
for (Map.Entry<String, Long> e : ipAccess.entrySet()) {
|
||||||
if (t - e.getValue().longValue() <= MAX_IDLE) {
|
if (t - e.getValue() <= MAX_IDLE) {
|
||||||
newMap.put(e.getKey(), e.getValue());
|
newMap.put(e.getKey(), e.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ public class DenseLongMapTest {
|
||||||
long k = (long) (rand.nextDouble() * keyrange);
|
long k = (long) (rand.nextDouble() * keyrange);
|
||||||
Long KK = k;
|
Long KK = k;
|
||||||
Integer VV = hmap.get(KK);
|
Integer VV = hmap.get(KK);
|
||||||
int hvalue = VV == null ? -1 : VV.intValue();
|
int hvalue = VV == null ? -1 : VV;
|
||||||
int dvalue = dmap.getInt(k);
|
int dvalue = dmap.getInt(k);
|
||||||
|
|
||||||
if (hvalue != dvalue) {
|
if (hvalue != dvalue) {
|
||||||
|
|
|
@ -52,7 +52,6 @@
|
||||||
<!-- <rule ref="category/java/bestpractices.xml/UnusedAssignment" /> -->
|
<!-- <rule ref="category/java/bestpractices.xml/UnusedAssignment" /> -->
|
||||||
<rule ref="category/java/codestyle.xml/UseDiamondOperator" />
|
<rule ref="category/java/codestyle.xml/UseDiamondOperator" />
|
||||||
<!-- <rule ref="category/java/design.xml/ImmutableField" /> -->
|
<!-- <rule ref="category/java/design.xml/ImmutableField" /> -->
|
||||||
<!-- Will be added in PMD 7 -->
|
<rule ref="category/java/codestyle.xml/UnnecessaryBoxing" />
|
||||||
<!-- <rule ref="category/java/codestyle.xml/UnnecessaryBoxing" /> -->
|
|
||||||
|
|
||||||
</ruleset>
|
</ruleset>
|
||||||
|
|
Loading…
Reference in a new issue