diff --git a/README.md b/README.md index 8da5faac3..3190036d1 100644 --- a/README.md +++ b/README.md @@ -154,5 +154,5 @@ In Eclipse, open the project *Properties / Java Build Path / Module Dependencies #### SpotBugs -* Make sure you configure SpotBugs with the /tools/FindBugsExcludeFilter.xml file. Otherwise, you will get a lot of false positive or low risk issues that we have examined and exliminated with this exclusion file. +* Make sure you configure SpotBugs with the /tools/FindBugsExcludeFilter.xml file. Otherwise, you may get a lot of false positive or low risk issues that we have examined and eliminated with this exclusion file. diff --git a/pom.xml b/pom.xml index 75016d7f7..02765d07f 100644 --- a/pom.xml +++ b/pom.xml @@ -150,6 +150,13 @@ under the License. ${testng.version} test + diff --git a/src/main/java/org/apache/datasketches/common/Util.java b/src/main/java/org/apache/datasketches/common/Util.java index 18e051261..f713171e6 100644 --- a/src/main/java/org/apache/datasketches/common/Util.java +++ b/src/main/java/org/apache/datasketches/common/Util.java @@ -24,6 +24,7 @@ import static java.lang.Math.log; import static java.lang.Math.pow; import static java.lang.Math.round; +import static java.util.Arrays.fill; import java.util.Comparator; @@ -217,7 +218,7 @@ public static String nanoSecToString(final long nS) { /** * Returns the given time in milliseconds formatted as Hours:Min:Sec.mSec - * @param mS the given nanoseconds + * @param mS the given milliseconds * @return the given time in milliseconds formatted as Hours:Min:Sec.mSec */ public static String milliSecToString(final long mS) { @@ -244,40 +245,20 @@ public static String zeroPad(final String s, final int fieldLength) { /** * Prepend or postpend the given string with the given character to fill the given field length. - * If the given string is equal or greater than the given field length, it will be returned - * without modification. + * If the given string is equal to or greater than the given field length, it will be returned without modification. * @param s the given string * @param fieldLength the desired field length * @param padChar the desired pad character * @param postpend if true append the pacCharacters to the end of the string. - * @return prepended or postpended given string with the given character to fill the given field - * length. + * @return prepended or postpended given string with the given character to fill the given field length. */ - public static String characterPad(final String s, final int fieldLength, final char padChar, - final boolean postpend) { - final char[] chArr = s.toCharArray(); - final int sLen = chArr.length; + public static String characterPad(final String s, final int fieldLength, final char padChar, final boolean postpend) { + final int sLen = s.length(); if (sLen < fieldLength) { - final char[] out = new char[fieldLength]; - final int blanks = fieldLength - sLen; - - if (postpend) { - for (int i = 0; i < sLen; i++) { - out[i] = chArr[i]; - } - for (int i = sLen; i < fieldLength; i++) { - out[i] = padChar; - } - } else { //prepend - for (int i = 0; i < blanks; i++) { - out[i] = padChar; - } - for (int i = blanks; i < fieldLength; i++) { - out[i] = chArr[i - blanks]; - } - } - - return String.valueOf(out); + final char[] cArr = new char[fieldLength - sLen]; + fill(cArr, padChar); + final String addstr = String.valueOf(cArr); + return (postpend) ? s.concat(addstr) : addstr.concat(s); } return s; } @@ -376,8 +357,8 @@ public static int ceilingIntPowerOf2(final int n) { } /** - * Computes the long ceiling power of 2 within the range [1, 2^30]. This is the smallest positive power - * of 2 that is equal to or greater than the given n and a mathematical integer. + * Computes the long ceiling power of 2 within the range [1, 2^62]. This is the smallest positive power + * of 2 that is equal to or greater than the given n and a mathematical long. * *

For: *