mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-05-28 08:26:14 +00:00
do not copy big byte arrays, store only references (ByteArrayRange) e.g in image tags
This commit is contained in:
@@ -696,6 +696,25 @@ public class SWFInputStream implements AutoCloseable {
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads byte range from the stream
|
||||
*
|
||||
* @param count Number of bytes to read
|
||||
* @param name
|
||||
* @return ByteArrayRange object
|
||||
* @throws IOException
|
||||
*/
|
||||
public ByteArrayRange readByteRangeEx(long count, String name) throws IOException {
|
||||
if (count <= 0) {
|
||||
return ByteArrayRange.EMPTY;
|
||||
}
|
||||
newDumpLevel(name, "bytes");
|
||||
int startPos = (int) getPos();
|
||||
skipBytesEx(count);
|
||||
endDumpLevel();
|
||||
return new ByteArrayRange(swf.uncompressedData, startPos, (int) count);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads bytes from the stream
|
||||
*
|
||||
@@ -718,6 +737,19 @@ public class SWFInputStream implements AutoCloseable {
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Skip bytes from the stream
|
||||
*
|
||||
* @param count Number of bytes to skip
|
||||
* @throws IOException
|
||||
*/
|
||||
public void skipBytesEx(long count) throws IOException {
|
||||
bitPos = 0;
|
||||
for (int i = 0; i < count; i++) {
|
||||
readNoBitReset();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Skip bytes from the stream
|
||||
*
|
||||
@@ -726,10 +758,7 @@ public class SWFInputStream implements AutoCloseable {
|
||||
*/
|
||||
public void skipBytes(long count) throws IOException {
|
||||
try {
|
||||
bitPos = 0;
|
||||
for (int i = 0; i < count; i++) {
|
||||
readNoBitReset();
|
||||
}
|
||||
skipBytesEx(count);
|
||||
} catch (EOFException | EndOfStreamException ex) {
|
||||
logger.log(Level.SEVERE, null, ex);
|
||||
}
|
||||
@@ -769,7 +798,7 @@ public class SWFInputStream implements AutoCloseable {
|
||||
InflaterInputStream dis = new InflaterInputStream(new ByteArrayInputStream(data));
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
if (count > 0) {
|
||||
byte[] buf = new byte[4096];
|
||||
byte[] buf = new byte[4096];
|
||||
int c = 0;
|
||||
while ((c = dis.read(buf)) > 0) {
|
||||
baos.write(buf, 0, c);
|
||||
|
||||
Reference in New Issue
Block a user