diff src/org/eclipse/jetty/io/BufferUtil.java @ 1020:6be43ef1eb96

HttpHeaderValues uses StringCache
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 31 Oct 2016 22:24:41 -0600
parents f126d30e04a4
children e350c11242be
line wrap: on
line diff
--- a/src/org/eclipse/jetty/io/BufferUtil.java	Mon Oct 31 03:33:42 2016 -0600
+++ b/src/org/eclipse/jetty/io/BufferUtil.java	Mon Oct 31 22:24:41 2016 -0600
@@ -72,31 +72,29 @@
 	}
 	
 	/**
-	 * Convert buffer to an long.
+	 * Convert string to an long.
 	 * Parses up to the first non-numeric character. If no number is found an
 	 * IllegalArgumentException is thrown
-	 * @param buffer A buffer containing an integer. The position is not changed.
-	 * @return an int 
 	 */
-	public static long toLong(Buffer buffer)
+	public static long toLong(String s)
 	{
-		long val= 0;
+		long val = 0;
 		boolean started= false;
 		boolean minus= false;
-		for (int i= buffer.getIndex(); i < buffer.putIndex(); i++)
+		for (int i = 0; i < s.length(); i++)
 		{
-			byte b= buffer.peek(i);
-			if (b <= SPACE)
+			char c = s.charAt(i);
+			if (c <= ' ')
 			{
 				if (started)
 					break;
 			}
-			else if (b >= '0' && b <= '9')
+			else if (c >= '0' && c <= '9')
 			{
-				val= val * 10L + (b - '0');
+				val= val * 10L + (c - '0');
 				started= true;
 			}
-			else if (b == MINUS && !started)
+			else if (c == '-' && !started)
 			{
 				minus= true;
 			}
@@ -106,7 +104,7 @@
 
 		if (started)
 			return minus ? (-val) : val;
-		throw new NumberFormatException(buffer.toString());
+		throw new NumberFormatException(s);
 	}
 
 	public static void putHexInt(Buffer buffer, int n)
@@ -235,13 +233,6 @@
 		}
 	}
 	
-	public static Buffer toBuffer(long value)
-	{
-		ByteArrayBuffer buf = new ByteArrayBuffer(32);
-		putDecLong(buf, value);
-		return buf;
-	}
-
 	private final static int[] hexDivisors=
 	{
 		0x10000000,
@@ -283,7 +274,7 @@
 		buffer.put((byte)13);
 		buffer.put((byte)10);
 	}
-	
+/*
 	public static boolean isPrefix(Buffer prefix,Buffer buffer)
 	{
 		if (prefix.length()>buffer.length())
@@ -294,7 +285,7 @@
 				return false;
 		return true;
 	}
-
+*/
 	public static String to8859_1_String(Buffer buffer)
 	{
 		if (buffer instanceof CachedBuffer)