do not copy big byte arrays, store only references (ByteArrayRange) e.g in image tags

This commit is contained in:
honfika@gmail.com
2014-11-09 22:40:36 +01:00
parent 270cc40856
commit 3456d04d38
151 changed files with 2787 additions and 2512 deletions

View File

@@ -23,7 +23,7 @@ package com.jpexs.helpers;
public class ByteArrayRange {
public static final ByteArrayRange EMPTY = new ByteArrayRange(new byte[0]);
private final byte[] array;
private final int pos;
private final int length;
@@ -43,18 +43,28 @@ public class ByteArrayRange {
public byte[] getArray() {
return array;
}
public int getPos() {
return pos;
}
public int getLength() {
return length;
}
public byte get(int index) {
return array[pos + index];
}
public byte[] getRangeData() {
byte[] data = new byte[length];
System.arraycopy(array, pos, data, 0, length);
return data;
}
public byte[] getRangeData(int pos, int length) {
byte[] data = new byte[length];
System.arraycopy(array, this.pos + pos, data, 0, length);
return data;
}
}