]> source.dussan.org Git - jackcess.git/commitdiff
more unit test perf tweaks
authorJames Ahlborn <jtahlborn@yahoo.com>
Mon, 13 Oct 2014 00:23:13 +0000 (00:23 +0000)
committerJames Ahlborn <jtahlborn@yahoo.com>
Mon, 13 Oct 2014 00:23:13 +0000 (00:23 +0000)
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@890 f203690c-595d-4dc9-a70b-905162fa7fd2

src/main/java/com/healthmarketscience/jackcess/impl/ByteUtil.java
src/test/java/com/healthmarketscience/jackcess/impl/IndexCodesTest.java

index 67f07240b15615db55dbd64c57936c98050863e5..5736bb3b90fcab6ab7ad3f5c6d43a4d2a19048a8 100644 (file)
@@ -450,7 +450,12 @@ public final class ByteUtil {
   public static String toHexString(ByteBuffer buffer,
                                    int offset, int size, boolean formatted) {
     
-    StringBuilder rtn = new StringBuilder();
+    int bufLen = size * 2;
+    if(formatted) {
+      bufLen += size + 
+        (7 * ((size + NUM_BYTES_PER_LINE - 1) / NUM_BYTES_PER_LINE));
+    }
+    StringBuilder rtn = new StringBuilder(bufLen);
     int position = buffer.position();
     buffer.position(offset);
     size = Math.min(size, buffer.remaining());
index ddee49199e905e8ec9964cd31f610afa5d7f4dfb..973484cb1dfb81c17b3678b1bd6185b15b4d547d 100644 (file)
@@ -792,8 +792,7 @@ public class IndexCodesTest extends TestCase {
     byte[] entryBytes = (byte[])ebField.get(entry);
 
     return ByteUtil.toHexString(ByteBuffer.wrap(entryBytes),
-                                entryBytes.length)
-      .trim().replaceAll("\\p{Space}+", " ");
+                                0, entryBytes.length, false);
   }
   
 }