Skip to content

Commit 817cff1

Browse files
committed
Remove dependencies on commons-codec.jar and guava-r09.jar (to reduce java method count by ~7900 methods)
1 parent c6e293c commit 817cff1

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

libs/commons-codec.jar

-45.6 KB
Binary file not shown.

libs/guava-r09.jar

-1.09 MB
Binary file not shown.

src/net/sqlcipher/DatabaseUtils.java

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@
3232
import java.util.HashMap;
3333
import java.util.Map;
3434

35-
import org.apache.commons.codec.binary.Hex;
36-
3735
import android.content.ContentValues;
3836
import android.content.OperationApplicationException;
3937
import android.os.Parcel;
@@ -323,10 +321,23 @@ public static String getCollationKey(String name) {
323321
*/
324322
public static String getHexCollationKey(String name) {
325323
byte [] arr = getCollationKeyInBytes(name);
326-
char[] keys = Hex.encodeHex(arr);
324+
char[] keys = encodeHex(arr, HEX_DIGITS_LOWER);
327325
return new String(keys, 0, getKeyLen(arr) * 2);
328326
}
329327

328+
private static final char[] HEX_DIGITS_LOWER = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
329+
330+
private static char[] encodeHex(final byte[] data, final char[] toDigits) {
331+
final int l = data.length;
332+
final char[] out = new char[l << 1];
333+
// two characters form the hex value.
334+
for (int i = 0, j = 0; i < l; i++) {
335+
out[j++] = toDigits[(0xF0 & data[i]) >>> 4];
336+
out[j++] = toDigits[0x0F & data[i]];
337+
}
338+
return out;
339+
}
340+
330341
private static int getKeyLen(byte[] arr) {
331342
if (arr[arr.length - 1] != 0) {
332343
return arr.length;

0 commit comments

Comments
 (0)