This is an automated email from the ASF dual-hosted git repository.

upthewaterspout pushed a commit to branch feature/redis-performance-testing
in repository https://gitbox.apache.org/repos/asf/geode.git

commit df8b1e324a0ab4c1e14ef8f7a282125d304be12d
Author: Jens Deppe <[email protected]>
AuthorDate: Thu Mar 4 06:52:20 2021 -0800

    Revert "Add fastIntToBytes"
    
    This reverts commit b947e83fd29f1876a3024db7b016fd4e8e12fcbc.
---
 .../apache/geode/redis/internal/netty/Coder.java   | 95 +---------------------
 1 file changed, 1 insertion(+), 94 deletions(-)

diff --git 
a/geode-redis/src/main/java/org/apache/geode/redis/internal/netty/Coder.java 
b/geode-redis/src/main/java/org/apache/geode/redis/internal/netty/Coder.java
index 57bc9b6..e0a0e52 100644
--- a/geode-redis/src/main/java/org/apache/geode/redis/internal/netty/Coder.java
+++ b/geode-redis/src/main/java/org/apache/geode/redis/internal/netty/Coder.java
@@ -327,100 +327,7 @@ public class Coder {
    */
 
   public static byte[] intToBytes(int i) {
-    // return stringToBytes(String.valueOf(i));
-    return fastIntToBytes(i);
-  }
-
-  private static byte[] fastIntToBytes(int i) {
-    if (i == Integer.MIN_VALUE) {
-      return "-2147483648".getBytes();
-    }
-
-    int size = (i < 0) ? stringSize(-i) + 1 : stringSize(i);
-    byte[] buffer = new byte[size];
-    getChars(i, size, buffer);
-
-    return buffer;
-  }
-
-  static void getChars(int i, int index, byte[] buffer) {
-    int q, r;
-    int charPos = index;
-    byte sign = 0;
-
-    if (i < 0) {
-      sign = '-';
-      i = -i;
-    }
-
-    // Generate two digits per iteration
-    while (i >= 65536) {
-      q = i / 100;
-      // really: r = i - (q * 100);
-      r = i - ((q << 6) + (q << 5) + (q << 2));
-      i = q;
-      buffer[--charPos] = DigitOnes[r];
-      buffer[--charPos] = DigitTens[r];
-    }
-
-    // Fall thru to fast mode for smaller numbers
-    // assert(i <= 65536, i);
-    for (;;) {
-      q = (i * 52429) >>> (16 + 3);
-      r = i - ((q << 3) + (q << 1)); // r = i-(q*10) ...
-      buffer[--charPos] = digits[r];
-      i = q;
-      if (i == 0)
-        break;
-    }
-    if (sign != 0) {
-      buffer[--charPos] = sign;
-    }
-  }
-
-  static final byte[] digits = {
-      0x30, 0x31, 0x32, 0x33, 0x34, 0x35,
-      0x36, 0x37, 0x38, 0x39, 0x61, 0x62,
-      0x63, 0x64, 0x65, 0x66, 0x67, 0x68,
-      0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e,
-      0x6f, 0x70, 0x71, 0x72, 0x73, 0x74,
-      0x75, 0x76, 0x77, 0x78, 0x79, 0x7a,
-  };
-
-  static final byte[] DigitOnes = {
-      0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39,
-      0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39,
-      0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39,
-      0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39,
-      0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39,
-      0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39,
-      0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39,
-      0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39,
-      0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39,
-      0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39,
-  };
-
-  static final byte[] DigitTens = {
-      0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,
-      0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31,
-      0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32,
-      0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33,
-      0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34,
-      0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35,
-      0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
-      0x37, 0x37, 0x37, 0x37, 0x37, 0x37, 0x37, 0x37, 0x37, 0x37,
-      0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38,
-      0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39,
-  };
-
-  static final int[] sizeTable = {9, 99, 999, 9999, 99999, 999999, 9999999,
-      99999999, 999999999, Integer.MAX_VALUE};
-
-  // Requires positive x
-  static int stringSize(int x) {
-    for (int i = 0;; i++)
-      if (x <= sizeTable[i])
-        return i + 1;
+    return stringToBytes(String.valueOf(i));
   }
 
   public static byte[] longToBytes(long l) {

Reply via email to