FindBugs 'Efficiency' fixes

This commit is contained in:
Eric Banks 2012-08-16 15:40:52 -04:00
parent d8071c66ed
commit 05cbf1c8c0
5 changed files with 7 additions and 61 deletions

View File

@ -262,18 +262,19 @@ public class ErrorModel {
}
public String toString() {
String result = "(";
StringBuilder result = new StringBuilder("(");
boolean skipComma = true;
for (double v : probabilityVector.getProbabilityVector()) {
if (skipComma) {
skipComma = false;
}
else {
result += ",";
result.append(",");
}
result += String.format("%.4f", v);
result.append(String.format("%.4f", v));
}
return result + ")";
result.append(")");
return result.toString();
}
public static int getTotalReferenceDepth(HashMap<String, ErrorModel> perLaneErrorModels) {

View File

@ -351,7 +351,6 @@ public class ProduceBeagleInput extends RodWalker<Integer, Integer> {
}
public static class CachingFormatter {
private int maxCacheSize = 0;
private String format;
private LRUCache<Double, String> cache;
@ -379,7 +378,6 @@ public class ProduceBeagleInput extends RodWalker<Integer, Integer> {
}
public CachingFormatter(String format, int maxCacheSize) {
this.maxCacheSize = maxCacheSize;
this.format = format;
this.cache = new LRUCache<Double, String>(maxCacheSize);
}

View File

@ -86,7 +86,7 @@ class PreciseNonNegativeDouble implements Comparable<PreciseNonNegativeDouble> {
if (Math.abs(logValDiff) <= EQUALS_THRESH)
return 0; // this.equals(other)
return new Double(Math.signum(logValDiff)).intValue();
return (int)Math.signum(logValDiff);
}
public boolean equals(PreciseNonNegativeDouble other) {

View File

@ -870,7 +870,7 @@ public class ReadBackedPhasing extends RodWalker<PhasingStatsAndOutput, PhasingS
int useOnLeft, useOnRight;
if (numOnLeft <= numOnRight) {
int halfToUse = new Double(Math.floor(numToUse / 2.0)).intValue(); // skimp on the left [floor], and be generous with the right side
int halfToUse = numToUse / 2; // skimp on the left [floor], and be generous with the right side
useOnLeft = Math.min(halfToUse, numOnLeft);
useOnRight = Math.min(numToUse - useOnLeft, numOnRight);
}

View File

@ -377,59 +377,6 @@ public class SWPairwiseAlignment {
return w_open+(k-1)*w_extend; // gap
}
private void print(int[][] s) {
for ( int i = 0 ; i < s.length ; i++) {
for ( int j = 0; j < s[i].length ; j++ ) {
System.out.printf(" %4d",s[i][j]);
}
System.out.println();
}
}
private void print(double[][] s) {
for ( int i = 0 ; i < s.length ; i++) {
for ( int j = 0; j < s[i].length ; j++ ) {
System.out.printf(" %4g",s[i][j]);
}
System.out.println();
}
}
private void print(int[][] s, String a, String b) {
System.out.print(" ");
for ( int j = 1 ; j < s[0].length ; j++) System.out.printf(" %4c",b.charAt(j-1)) ;
System.out.println();
for ( int i = 0 ; i < s.length ; i++) {
if ( i > 0 ) System.out.print(a.charAt(i-1));
else System.out.print(' ');
System.out.print(" ");
for ( int j = 0; j < s[i].length ; j++ ) {
System.out.printf(" %4d",s[i][j]);
}
System.out.println();
}
}
private void print(double[][] s, String a, String b) {
System.out.print("");
for ( int j = 1 ; j < s[0].length ; j++) System.out.printf(" %4c",b.charAt(j-1)) ;
System.out.println();
for ( int i = 0 ; i < s.length ; i++) {
if ( i > 0 ) System.out.print(a.charAt(i-1));
else System.out.print(' ');
System.out.print(" ");
for ( int j = 0; j < s[i].length ; j++ ) {
System.out.printf(" %2.1f",s[i][j]);
}
System.out.println();
}
}
private void print(double[] s, byte[] a, byte[] b) {
int n = a.length+1;
int m = b.length+1;