From f8ba282d71706527ae6c2b787d2abc407276475f Mon Sep 17 00:00:00 2001 From: James Ahlborn Date: Mon, 13 Oct 2014 00:23:13 +0000 Subject: [PATCH] more unit test perf tweaks git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@890 f203690c-595d-4dc9-a70b-905162fa7fd2 --- .../com/healthmarketscience/jackcess/impl/ByteUtil.java | 7 ++++++- .../healthmarketscience/jackcess/impl/IndexCodesTest.java | 3 +-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/healthmarketscience/jackcess/impl/ByteUtil.java b/src/main/java/com/healthmarketscience/jackcess/impl/ByteUtil.java index 67f0724..5736bb3 100644 --- a/src/main/java/com/healthmarketscience/jackcess/impl/ByteUtil.java +++ b/src/main/java/com/healthmarketscience/jackcess/impl/ByteUtil.java @@ -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()); diff --git a/src/test/java/com/healthmarketscience/jackcess/impl/IndexCodesTest.java b/src/test/java/com/healthmarketscience/jackcess/impl/IndexCodesTest.java index ddee491..973484c 100644 --- a/src/test/java/com/healthmarketscience/jackcess/impl/IndexCodesTest.java +++ b/src/test/java/com/healthmarketscience/jackcess/impl/IndexCodesTest.java @@ -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); } } -- 2.39.5