db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: rev 56617 - incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types
Date Thu, 04 Nov 2004 19:45:45 GMT
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);
 	}
 
 	/**

Mime
View raw message