changeset 1052:4a2489f1d5fe

remove JBuffer.peek()
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 08 Nov 2016 00:27:16 -0700
parents 1ab2dd0a7db5
children 7e4b41247544
files src/org/eclipse/jetty/http/HttpParser.java src/org/eclipse/jetty/io/BufferUtil.java src/org/eclipse/jetty/io/JBuffer.java
diffstat 3 files changed, 11 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
diff -r 1ab2dd0a7db5 -r 4a2489f1d5fe src/org/eclipse/jetty/http/HttpParser.java
--- a/src/org/eclipse/jetty/http/HttpParser.java	Tue Nov 08 00:18:45 2016 -0700
+++ b/src/org/eclipse/jetty/http/HttpParser.java	Tue Nov 08 00:27:16 2016 -0700
@@ -122,6 +122,10 @@
 		return dup;
 	}
 
+	public byte peek() {
+		return _buffer.get(_buffer.position());
+	}
+
 
 	public long getContentLength()
 	{
@@ -571,7 +575,7 @@
 
 									_contentPosition=0;
 									_eol=ch;
-									if (_eol==HttpTokens.CARRIAGE_RETURN && _buffer.hasRemaining() && _buffer.peek()==HttpTokens.LINE_FEED)
+									if (_eol==HttpTokens.CARRIAGE_RETURN && _buffer.hasRemaining() && peek()==HttpTokens.LINE_FEED)
 										_eol=_buffer.get();
 
 									// We convert _contentLength to an int for this switch statement because
@@ -781,7 +785,7 @@
 					last=_state;
 				}
 
-				if (_eol == HttpTokens.CARRIAGE_RETURN && _buffer.peek() == HttpTokens.LINE_FEED)
+				if (_eol == HttpTokens.CARRIAGE_RETURN && peek() == HttpTokens.LINE_FEED)
 				{
 					_eol=_buffer.get();
 					length=_buffer.remaining();
@@ -833,7 +837,7 @@
 
 					case STATE_CHUNKED_CONTENT:
 					{
-						ch=_buffer.peek();
+						ch=peek();
 						if (ch == HttpTokens.CARRIAGE_RETURN || ch == HttpTokens.LINE_FEED)
 							_eol=_buffer.get();
 						else if (ch <= HttpTokens.SPACE)
@@ -856,7 +860,7 @@
 
 							if (_chunkLength == 0)
 							{
-								if (_eol==HttpTokens.CARRIAGE_RETURN && _buffer.hasRemaining() && _buffer.peek()==HttpTokens.LINE_FEED)
+								if (_eol==HttpTokens.CARRIAGE_RETURN && _buffer.hasRemaining() && peek()==HttpTokens.LINE_FEED)
 									_eol=_buffer.get();
 								_state = _persistent?STATE_END:STATE_SEEKING_EOF;
 								_handler.messageComplete(_contentPosition);
@@ -886,7 +890,7 @@
 							_eol=ch;
 							if (_chunkLength == 0)
 							{
-								if (_eol==HttpTokens.CARRIAGE_RETURN && _buffer.hasRemaining() && _buffer.peek()==HttpTokens.LINE_FEED)
+								if (_eol==HttpTokens.CARRIAGE_RETURN && _buffer.hasRemaining() && peek()==HttpTokens.LINE_FEED)
 									_eol=_buffer.get();
 								_state = _persistent?STATE_END:STATE_SEEKING_EOF;
 								_handler.messageComplete(_contentPosition);
diff -r 1ab2dd0a7db5 -r 4a2489f1d5fe src/org/eclipse/jetty/io/BufferUtil.java
--- a/src/org/eclipse/jetty/io/BufferUtil.java	Tue Nov 08 00:18:45 2016 -0700
+++ b/src/org/eclipse/jetty/io/BufferUtil.java	Tue Nov 08 00:27:16 2016 -0700
@@ -48,7 +48,7 @@
 		boolean minus= false;
 		for (int i= buffer.getIndex(); i < buffer.putIndex(); i++)
 		{
-			byte b= buffer.peek(i);
+			byte b = buffer.get(i);
 			if (b <= SPACE)
 			{
 				if (started)
diff -r 1ab2dd0a7db5 -r 4a2489f1d5fe src/org/eclipse/jetty/io/JBuffer.java
--- a/src/org/eclipse/jetty/io/JBuffer.java	Tue Nov 08 00:18:45 2016 -0700
+++ b/src/org/eclipse/jetty/io/JBuffer.java	Tue Nov 08 00:27:16 2016 -0700
@@ -210,19 +210,9 @@
 		pokeBuffer(index).put(b);
 	}
 
-	private JBuffer peekBuffer(int index) {
-		JBuffer dup = duplicate();
-		dup.setGetIndex(index);
-		dup.setPutIndex(dup.capacity());
-		return dup;
-	}
 
-	public byte peek(int index) {
+	public byte get(int index) {
 		return bb.get(index);
 	}
 
-	public byte peek() {
-		return peek(bb.position());
-	}
-
 }