You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by dj...@apache.org on 2004/11/04 20:45:45 UTC

svn commit: rev 56617 - incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types

Author: djd
Date: Thu Nov  4 11:45:44 2004
New Revision: 56617

Modified:
   incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLDecimal.java
Log:
Modify SQLDecimal.writeExternal() to use BigDecimal.unscaledValue() that
could not be used while Derby (Cloudscape) supported JDK1.1. This makes
storing DECIMAL values more efficient due to less object creation.

Remove some dead code.



Modified: incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLDecimal.java
==============================================================================
--- incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLDecimal.java	(original)
+++ incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLDecimal.java	Thu Nov  4 11:45:44 2004
@@ -409,7 +409,7 @@
 
 		if (value != null) {
 			scale = value.scale();
-			BigInteger bi = value.movePointRight(scale).toBigInteger();
+			BigInteger bi = value.unscaledValue();
 			byteArray = bi.toByteArray();
 		} else {
 			scale = rawScale;
@@ -448,25 +448,8 @@
 		if ((rawData == null) || size != rawData.length)
 		{
 			rawData = new byte[size];
-			in.readFully(rawData);
-		}
-		/*
-		** Copy the incoming array into the last
-		** bytes of the existing array.  BigInteger
-		** is implemented to ignore leading zeroed bytes.
-		*/
-		else
-		{
-			// zero out the leading bytes
-			int stop = (rawData.length - size);
-			for (int i = 0; i < stop; i++)
-			{
-				rawData[i] = 0;
-			}
-			in.readFully(rawData,
-					     stop,  // start at rawData[stop]
-					     size); // read in size bytes
 		}
+		in.readFully(rawData);
 
 	}
 	public void readExternalFromArray(ArrayInputStream in) throws IOException 
@@ -489,26 +472,8 @@
 		if ((rawData == null) || size != rawData.length)
 		{
 			rawData = new byte[size];
-			in.readFully(rawData);
 		}
-		/*
-		** Copy the incoming array into the last
-		** bytes of the existing array.  BigInteger
-		** is implemented to ignore leading zeroed bytes.
-		*/
-		else
-		{
-			// zero out the leading bytes
-			int stop = (rawData.length - size);
-			for (int i = 0; i < stop; i++)
-			{
-				rawData[i] = 0;
-			}
-			in.readFully(rawData,
-					     stop,  // start at rawData[stop]
-					     size); // read in size bytes
-		}
-
+		in.readFully(rawData);
 	}
 
 	/**