You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by sj...@apache.org on 2008/07/14 12:31:28 UTC
svn commit: r676545 -
/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/BHSDCodec.java
Author: sjanuary
Date: Mon Jul 14 03:31:27 2008
New Revision: 676545
URL: http://svn.apache.org/viewvc?rev=676545&view=rev
Log:
Apply patch for HARMONY-5910 ([classlib][pack200][performance] BHSDCodec.decode() optimization)
Modified:
harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/BHSDCodec.java
Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/BHSDCodec.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/BHSDCodec.java?rev=676545&r1=676544&r2=676545&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/BHSDCodec.java (original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/BHSDCodec.java Mon Jul 14 03:31:27 2008
@@ -113,6 +113,11 @@
private final long largest;
/**
+ * radix^i powers
+ */
+ private long[] powers;
+
+ /**
* Constructs an unsigned, non-delta Codec with the given B and H values.
*
* @param b
@@ -182,6 +187,11 @@
}
smallest = calculateSmallest();
largest = calculateLargest();
+
+ powers = new long[b];
+ for(int c = 0; c < b; c++) {
+ powers[c] = (long)Math.pow(h, c);
+ }
}
/**
@@ -205,14 +215,16 @@
Pack200Exception {
int n = 0;
long z = 0;
- long x;
+ long x = 0;
+
do {
x = in.read();
- if (x == -1)
- throw new EOFException("End of stream reached whilst decoding");
- z += x * Math.pow(h, n);
+ z += x * powers[n];
n++;
- } while (n < b & isHigh(x));
+ } while (x >= l && n < b);
+
+ if (x == -1)
+ throw new EOFException("End of stream reached whilst decoding");
if (isSigned()) {
int u = ((1 << s) - 1);
@@ -249,10 +261,6 @@
// return u;
// }
- private boolean isHigh(long x) {
- return x >= l;
- }
-
/**
* True if this encoding can code the given value
*