Premature optimization removed from preloader
This commit is contained in:
@@ -142,16 +142,15 @@ public class ClassPreloadingUtils {
|
|||||||
if (resources.containsKey(name)) continue; // Only the first resource is stored
|
if (resources.containsKey(name)) continue; // Only the first resource is stored
|
||||||
|
|
||||||
int size = (int) entry.getSize();
|
int size = (int) entry.getSize();
|
||||||
boolean unknownArraySize = size < 0;
|
int effectiveSize = size < 0 ? 32 : size;
|
||||||
int effectiveSize = unknownArraySize ? 32 : size;
|
ByteArrayOutputStream bytes = new ByteArrayOutputStream(effectiveSize);
|
||||||
ByteArrayOutputStreamWithPublicArray bytes = new ByteArrayOutputStreamWithPublicArray(effectiveSize);
|
|
||||||
|
|
||||||
int count;
|
int count;
|
||||||
while ((count = stream.read(buffer)) > 0) {
|
while ((count = stream.read(buffer)) > 0) {
|
||||||
bytes.write(buffer, 0, count);
|
bytes.write(buffer, 0, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
resources.put(name, new ResourceData(jarFile, name, unknownArraySize ? bytes.toByteArray() : bytes.getBytes()));
|
resources.put(name, new ResourceData(jarFile, name, bytes.toByteArray()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
@@ -170,17 +169,6 @@ public class ClassPreloadingUtils {
|
|||||||
return resources;
|
return resources;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class ByteArrayOutputStreamWithPublicArray extends ByteArrayOutputStream {
|
|
||||||
public ByteArrayOutputStreamWithPublicArray(int size) {
|
|
||||||
super(size);
|
|
||||||
}
|
|
||||||
|
|
||||||
// To avoid copying the array
|
|
||||||
public byte[] getBytes() {
|
|
||||||
return buf;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class ResourceData {
|
private static class ResourceData {
|
||||||
private final File jarFile;
|
private final File jarFile;
|
||||||
private final String resourceName;
|
private final String resourceName;
|
||||||
|
|||||||
Reference in New Issue
Block a user