Skip to content

Commit 59e5fde

Browse files
committed
fix wrong ordering of buffered wrapping
1 parent 130c5c5 commit 59e5fde

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

core/src/processing/core/PApplet.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6920,18 +6920,19 @@ static public PrintWriter createWriter(OutputStream output) {
69206920
*
69216921
*/
69226922
public InputStream createInput(String filename) {
6923-
InputStream input = new BufferedInputStream(createInputRaw(filename));
6923+
InputStream input = createInputRaw(filename);
69246924
final String lower = filename.toLowerCase();
69256925
if ((input != null) &&
69266926
(lower.endsWith(".gz") || lower.endsWith(".svgz"))) {
69276927
try {
6928-
return new GZIPInputStream(input);
6928+
// buffered has to go *around* the GZ, otherwise 25x slower
6929+
return new BufferedInputStream(new GZIPInputStream(input));
69296930
} catch (IOException e) {
69306931
printStackTrace(e);
69316932
return null;
69326933
}
69336934
}
6934-
return input;
6935+
return new BufferedInputStream(input);
69356936
}
69366937

69376938

@@ -7103,11 +7104,11 @@ static public InputStream createInput(File file) {
71037104
throw new IllegalArgumentException("File passed to createInput() was null");
71047105
}
71057106
try {
7106-
InputStream input = new BufferedInputStream(new FileInputStream(file));
7107+
InputStream input = new FileInputStream(file);
71077108
if (file.getName().toLowerCase().endsWith(".gz")) {
7108-
return new GZIPInputStream(input);
7109+
return new BufferedInputStream(new GZIPInputStream(input));
71097110
}
7110-
return input;
7111+
return new BufferedInputStream(input);
71117112

71127113
} catch (IOException e) {
71137114
System.err.println("Could not createInput() for " + file);

0 commit comments

Comments
 (0)