Optimize buffer size (#1013)

This commit is contained in:
MakKi (makki_d) 2018-05-24 00:26:47 +09:00 committed by Sean Owen
parent a372dfe175
commit fa0e1d7556
2 changed files with 2 additions and 2 deletions

View file

@ -339,7 +339,7 @@ public final class BitArray implements Cloneable {
@Override
public String toString() {
StringBuilder result = new StringBuilder(size);
StringBuilder result = new StringBuilder(size + (size / 8) + 1);
for (int i = 0; i < size; i++) {
if ((i & 0x07) == 0) {
result.append(' ');

View file

@ -200,7 +200,7 @@ public final class BitMatrix implements Cloneable {
|| rowSize != mask.getRowSize()) {
throw new IllegalArgumentException("input matrix dimensions do not match");
}
BitArray rowArray = new BitArray(width / 32 + 1);
BitArray rowArray = new BitArray(width);
for (int y = 0; y < height; y++) {
int offset = y * rowSize;
int[] row = mask.getRow(y, rowArray).getBitArray();