diff src/org/eclipse/jetty/io/BufferUtil.java @ 1056:7d872cc72ec2

minor
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 08 Nov 2016 01:19:36 -0700
parents e6ca3cb52837
children 013939bfc9e8
line wrap: on
line diff
--- a/src/org/eclipse/jetty/io/BufferUtil.java	Tue Nov 08 01:08:20 2016 -0700
+++ b/src/org/eclipse/jetty/io/BufferUtil.java	Tue Nov 08 01:19:36 2016 -0700
@@ -30,48 +30,9 @@
  */
 public final class BufferUtil
 {
-	static final byte SPACE= 0x20;
-	static final byte MINUS= '-';
-	static final byte[] DIGIT=
+	private static final byte[] DIGIT=
 	{(byte)'0',(byte)'1',(byte)'2',(byte)'3',(byte)'4',(byte)'5',(byte)'6',(byte)'7',(byte)'8',(byte)'9',(byte)'A',(byte)'B',(byte)'C',(byte)'D',(byte)'E',(byte)'F'};
 
-	/**
-	 * Convert buffer to an integer.
-	 * 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 int toInt(JBuffer buffer)
-	{
-		int val= 0;
-		boolean started= false;
-		boolean minus= false;
-		for (int i= buffer.getIndex(); i < buffer.putIndex(); i++)
-		{
-			byte b = buffer.get(i);
-			if (b <= SPACE)
-			{
-				if (started)
-					break;
-			}
-			else if (b >= '0' && b <= '9')
-			{
-				val= val * 10 + (b - '0');
-				started= true;
-			}
-			else if (b == MINUS && !started)
-			{
-				minus= true;
-			}
-			else
-				break;
-		}
-
-		if (started)
-			return minus ? (-val) : val;
-		throw new NumberFormatException(getString(buffer.duplicate()));
-	}
 	
 	/**
 	 * Convert string to an long.
@@ -150,7 +111,7 @@
 				}
 
 				started= true;
-				int d= n / hexDivisors[i];
+				int d = n / hexDivisors[i];
 				buffer.put(DIGIT[d]);
 				n= n - d * hexDivisors[i];
 			}
@@ -204,10 +165,10 @@
 			if (n == Long.MIN_VALUE)
 			{
 				buffer.put((byte)'9');
-				n= 223372036854775808L;
+				n = 223372036854775808L;
 			}
 			else
-				n= -n;
+				n = -n;
 		}
 
 		if (n < 10)