# HG changeset patch # User hannesw # Date 1360758621 -3600 # Node ID cab69ca3490d5e20e8f85fe910015c5f2b3413b0 # Parent df28320aa0809e2e04a528a48892012ce5b9ae89 8008096: TokenStream buffer should grow exponentially Reviewed-by: attila, lagergren, sundar diff -r df28320aa080 -r cab69ca3490d nashorn/src/jdk/nashorn/internal/parser/TokenStream.java --- a/nashorn/src/jdk/nashorn/internal/parser/TokenStream.java Tue Feb 12 12:47:51 2013 +0100 +++ b/nashorn/src/jdk/nashorn/internal/parser/TokenStream.java Wed Feb 13 13:30:21 2013 +0100 @@ -34,8 +34,8 @@ * */ public class TokenStream { - /** Buffer growth factor. */ - private static final int growth = 256; + /** Initial buffer size. */ + private static final int INITIAL_SIZE = 256; /** Token buffer. */ private long[] buffer; @@ -56,7 +56,7 @@ * Constructor. */ public TokenStream() { - buffer = new long[growth]; + buffer = new long[INITIAL_SIZE]; count = 0; in = 0; out = 0; @@ -193,7 +193,7 @@ */ public void grow() { // Allocate new buffer. - final long[] newBuffer = new long[buffer.length + growth]; + final long[] newBuffer = new long[buffer.length * 2]; // If single chunk. if (in > out) {