db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r497003 - in /db/derby/code/trunk/java: engine/org/apache/derby/iapi/services/io/FormatableBitSet.java testing/org/apache/derbyTesting/unitTests/junit/FormatableBitSetTest.java
Date Wed, 17 Jan 2007 11:49:17 GMT
Author: kahatlen
Date: Wed Jan 17 03:49:16 2007
New Revision: 497003

URL: http://svn.apache.org/viewvc?view=rev&rev=497003
Log:
DERBY-2191: Cleanup of FormatableBitSet
* remove unused import
* simplify calculation in numBytesFromBits()
* removed unused variables in toString()

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/io/FormatableBitSet.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/FormatableBitSetTest.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/io/FormatableBitSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/io/FormatableBitSet.java?view=diff&rev=497003&r1=497002&r2=497003
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/io/FormatableBitSet.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/io/FormatableBitSet.java
Wed Jan 17 03:49:16 2007
@@ -24,7 +24,6 @@
 import org.apache.derby.iapi.services.sanity.SanityManager;
 import org.apache.derby.iapi.util.ReuseFactory;
 
-import java.io.InputStream;
 import java.io.ObjectOutput;
 import java.io.ObjectInput;
 import java.io.IOException;
@@ -675,10 +674,8 @@
 	*
 	* @return	the number of bytes
 	*/
-	protected static int
-	numBytesFromBits(int bits)
-	{
-		return (bits == 0) ? 0 : ((bits - 1) / 8) + 1;
+	private static int numBytesFromBits(int bits) {
+		return (bits + 7) >> 3;
 	}
 
 	/**
@@ -804,17 +801,12 @@
 	 */
 	public String toString()
 	{
-		char[]	outChars;
-		int		inPosition;
-		int		outPosition;
-		int 	inByte;
-
 		{
 			// give it a reasonable size
 			StringBuffer str = new StringBuffer(getLength()*8*3);
 			str.append("{");
 			boolean first = true;
-			for (inPosition = 0; inPosition < getLength(); inPosition++)
+			for (int inPosition = 0; inPosition < getLength(); inPosition++)
 			{
 				if (isSet(inPosition))
 				{

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/FormatableBitSetTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/FormatableBitSetTest.java?view=diff&rev=497003&r1=497002&r2=497003
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/FormatableBitSetTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/FormatableBitSetTest.java
Wed Jan 17 03:49:16 2007
@@ -148,8 +148,8 @@
         // Should throw an exception?
         FormatableBitSet negBits = new FormatableBitSet(-1);
         assertEquals(-1,negBits.getLength());
-        assertEquals(1,negBits.getLengthInBytes());
-        assertEquals(1,negBits.getByteArray().length);
+        assertEquals(0,negBits.getLengthInBytes());
+        assertEquals(0,negBits.getByteArray().length);
         assertEquals(0,negBits.getNumBitsSet());
     }
 



Mime
View raw message