changeset 1039:a7319f14ba1e

remove Buffer.isImmutable()
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 03 Nov 2016 22:55:28 -0600
parents b71ad168fe34
children 3e4949834f3e
files src/org/eclipse/jetty/http/AbstractGenerator.java src/org/eclipse/jetty/http/HttpGenerator.java src/org/eclipse/jetty/io/AbstractBuffer.java src/org/eclipse/jetty/io/Buffer.java src/org/eclipse/jetty/io/ByteArrayBuffer.java src/org/eclipse/jetty/io/View.java
diffstat 6 files changed, 13 insertions(+), 40 deletions(-) [+]
line wrap: on
line diff
diff -r b71ad168fe34 -r a7319f14ba1e src/org/eclipse/jetty/http/AbstractGenerator.java
--- a/src/org/eclipse/jetty/http/AbstractGenerator.java	Thu Nov 03 22:16:11 2016 -0600
+++ b/src/org/eclipse/jetty/http/AbstractGenerator.java	Thu Nov 03 22:55:28 2016 -0600
@@ -245,7 +245,7 @@
 	{
 		if (_buffer != null && _buffer.space()==0)
 		{
-			if (_buffer.remaining()==0 && !_buffer.isImmutable())
+			if (_buffer.remaining()==0)
 				_buffer.compact();
 			return _buffer.space()==0;
 		}
diff -r b71ad168fe34 -r a7319f14ba1e src/org/eclipse/jetty/http/HttpGenerator.java
--- a/src/org/eclipse/jetty/http/HttpGenerator.java	Thu Nov 03 22:16:11 2016 -0600
+++ b/src/org/eclipse/jetty/http/HttpGenerator.java	Thu Nov 03 22:55:28 2016 -0600
@@ -20,11 +20,11 @@
 
 import java.io.IOException;
 import java.io.InterruptedIOException;
+import java.util.Arrays;
 
 import org.eclipse.jetty.io.Buffer;
 import org.eclipse.jetty.io.BufferUtil;
 import org.eclipse.jetty.io.Buffers;
-import org.eclipse.jetty.io.ByteArrayBuffer;
 import org.eclipse.jetty.io.EndPoint;
 import org.eclipse.jetty.io.EofException;
 import org.eclipse.jetty.util.StringUtil;
@@ -46,8 +46,8 @@
 	// Build cache of response lines for status
 	private static class Status
 	{
-		Buffer _schemeCode;
-		Buffer _responseLine;
+		byte[] _schemeCode;
+		byte[] _responseLine;
 	}
 	private static final Status[] __status = new Status[HttpStatus.MAX_CODE+1];
 	static
@@ -74,8 +74,8 @@
 			bytes[versionLength+6+reason.length()]=HttpTokens.LINE_FEED;
 
 			__status[i] = new Status();
-			__status[i]._schemeCode=new ByteArrayBuffer(bytes,0,versionLength+5,Buffer.IMMUTABLE);
-			__status[i]._responseLine=new ByteArrayBuffer(bytes,0,bytes.length,Buffer.IMMUTABLE);
+			__status[i]._schemeCode = Arrays.copyOf(bytes,versionLength+5);
+			__status[i]._responseLine = bytes;
 		}
 	}
 
diff -r b71ad168fe34 -r a7319f14ba1e src/org/eclipse/jetty/io/AbstractBuffer.java
--- a/src/org/eclipse/jetty/io/AbstractBuffer.java	Thu Nov 03 22:16:11 2016 -0600
+++ b/src/org/eclipse/jetty/io/AbstractBuffer.java	Thu Nov 03 22:55:28 2016 -0600
@@ -39,7 +39,7 @@
 	
 	protected final static String __READONLY = "READONLY";
 	
-	protected int _access;
+	int _access;
 
 	protected int _get;
 	protected int _put;
@@ -47,13 +47,12 @@
 	protected int _hashGet;
 	protected int _hashPut;
 	protected int _mark;
-	protected String _string;
 	protected View _view;
 
 	/**
 	 * Constructor for BufferView
 	 * 
-	 * @param access 0==IMMUTABLE, 1==READONLY, 2==READWRITE
+	 * @param access 1==READONLY, 2==READWRITE
 	 */
 	protected AbstractBuffer(int access)
 	{
@@ -212,11 +211,6 @@
 		return _hash;
 	}
 
-	public boolean isImmutable()
-	{
-		return _access <= IMMUTABLE;
-	}
-
 	public boolean isReadOnly()
 	{
 		return _access <= READONLY;
@@ -470,15 +464,6 @@
 	@Override
 	public String toString()
 	{
-/*
-		if (isImmutable())
-		{
-			if (_string == null) 
-				_string = new String(asArray(), 0, remaining());
-			return _string;
-		}
-		return new String(asArray(), 0, remaining());
-*/
 		return toString("ISO-8859-1");
 	}
 
diff -r b71ad168fe34 -r a7319f14ba1e src/org/eclipse/jetty/io/Buffer.java
--- a/src/org/eclipse/jetty/io/Buffer.java	Thu Nov 03 22:16:11 2016 -0600
+++ b/src/org/eclipse/jetty/io/Buffer.java	Thu Nov 03 22:55:28 2016 -0600
@@ -40,10 +40,9 @@
  *
  * @version 1.0
  */
-public interface Buffer extends Cloneable
+public interface Buffer
 {
 	public final static int 
-	  IMMUTABLE=0,  // neither indexes or contexts can be changed
 	  READONLY=1,   // indexes may be changed, but not content
 	  READWRITE=2;  // anything can be changed
 
@@ -126,13 +125,6 @@
 	
 	/**
 	 * 
-	 * @return a <code>boolean</code> value true if the buffer is immutable and that neither
-	 * the buffer contents nor the indexes may be changed.
-	 */
-	boolean isImmutable();
-	
-	/**
-	 * 
 	 * @return a <code>boolean</code> value true if the buffer is readonly. The buffer indexes may
 	 * be modified, but the buffer contents may not. For example a View onto an immutable Buffer will be
 	 * read only.
diff -r b71ad168fe34 -r a7319f14ba1e src/org/eclipse/jetty/io/ByteArrayBuffer.java
--- a/src/org/eclipse/jetty/io/ByteArrayBuffer.java	Thu Nov 03 22:16:11 2016 -0600
+++ b/src/org/eclipse/jetty/io/ByteArrayBuffer.java	Thu Nov 03 22:55:28 2016 -0600
@@ -50,11 +50,10 @@
 
 	public ByteArrayBuffer(byte[] bytes, int index, int length, int access)
 	{
-		super(READWRITE);
+		super(access);
 		_bytes = bytes;
 		setPutIndex(index + length);
 		setGetIndex(index);
-		_access = access;
 	}
 
 	public ByteArrayBuffer(int size)
@@ -65,12 +64,10 @@
 
 	public ByteArrayBuffer(String value)
 	{
-		super(READWRITE);
+		super(READONLY);
 		_bytes = StringUtil.getBytes(value);
 		setGetIndex(0);
 		setPutIndex(_bytes.length);
-		_access=IMMUTABLE;
-		_string = value;
 	}
 
 	@Override
diff -r b71ad168fe34 -r a7319f14ba1e src/org/eclipse/jetty/io/View.java
--- a/src/org/eclipse/jetty/io/View.java	Thu Nov 03 22:16:11 2016 -0600
+++ b/src/org/eclipse/jetty/io/View.java	Thu Nov 03 22:55:28 2016 -0600
@@ -38,12 +38,11 @@
 	 */
 	public View(Buffer buffer, int mark, int get, int put,int access)
 	{
-		super(READWRITE);
-		_buffer=buffer.buffer();
+		super(access);
+		_buffer = buffer.buffer();
 		setPutIndex(put);
 		setGetIndex(get);
 		setMarkIndex(mark);
-		_access=access;
 	}
 	
 	public View()