Skip to content

Commit

Permalink
re-use (empty) array byte[0]
Browse files Browse the repository at this point in the history
  • Loading branch information
kares committed Nov 11, 2015
1 parent 671fd59 commit f361890
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion core/src/main/java/org/jruby/util/Dir.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import org.jruby.Ruby;
import org.jruby.RubyEncoding;
import org.jruby.platform.Platform;
import static org.jruby.util.ByteList.NULL_ARRAY;

/**
* This class exists as a counterpart to the dir.c file in
Expand All @@ -59,7 +60,7 @@ public class Dir {
public final static int FNM_NOMATCH = 1;
public final static int FNM_ERROR = 2;

public final static byte[] EMPTY = new byte[0];
public final static byte[] EMPTY = NULL_ARRAY; // new byte[0];
public final static byte[] SLASH = new byte[]{'/'};
public final static byte[] STAR = new byte[]{'*'};
public final static byte[] DOUBLE_STAR = new byte[]{'*','*'};
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/java/org/jruby/util/io/OpenFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -926,7 +926,7 @@ public void makeReadConversion(ThreadContext context, int size) {
dname = encs.enc.getName();
}
else {
sname = dname = new byte[0];
sname = dname = EMPTY_BYTE_ARRAY;
}
readconv = EncodingUtils.econvOpenOpts(context, sname, dname, ecflags, ecopts);
if (readconv == null)
Expand Down Expand Up @@ -1022,7 +1022,7 @@ public int IO_RBUF_CAPA_FOR() {
}
public static final int IO_WBUF_CAPA_MIN = 8192;

private static final byte[] EMPTY_BYTE_ARRAY = new byte[0];
private static final byte[] EMPTY_BYTE_ARRAY = ByteList.NULL_ARRAY;

// MRI: appendline
public int appendline(ThreadContext context, int delim, ByteList[] strp, int[] lp) {
Expand Down

0 comments on commit f361890

Please sign in to comment.