Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jcodings
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 4196dba276d1
Choose a base ref
...
head repository: jruby/jcodings
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 9f28476de99e
Choose a head ref
  • 2 commits
  • 1 file changed
  • 2 contributors

Commits on Feb 26, 2018

  1. Buffer input stream reads in ArrayReader to avoid cost of many single…

    …-byte reads.
    
    Individual reads from ZipFileInputStream, as would be encountered when reading a resource from a JAR, can be very inefficient. They allocate a single-byte array and require unzipping the source file for each read (at least in OpenJDK 8).
    nirvdrum committed Feb 26, 2018
    Copy the full SHA
    437dfb3 View commit details
  2. Merge pull request #21 from nirvdrum/more-efficient-array-reader

    Reduce the number of individual InputStream#read calls by reading in batches.
    headius authored Feb 26, 2018
    Copy the full SHA
    9f28476 View commit details
Showing with 2 additions and 1 deletion.
  1. +2 −1 src/org/jcodings/util/ArrayReader.java
3 changes: 2 additions & 1 deletion src/org/jcodings/util/ArrayReader.java
Original file line number Diff line number Diff line change
@@ -19,6 +19,7 @@
*/
package org.jcodings.util;

import java.io.BufferedInputStream;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -31,7 +32,7 @@ public static DataInputStream openStream(String name) {
String entry = "/tables/" + name + ".bin";
InputStream is = ArrayReader.class.getResourceAsStream(entry);
if (is == null) throw new InternalException("entry: " + entry + " not found");
return new DataInputStream(is);
return new DataInputStream(new BufferedInputStream(is));
}

public static byte[] readByteArray(String name) {