summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenny Root <kroot@google.com>2011-07-25 12:32:01 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-07-25 12:32:01 -0700
commit5ccdaa9a0354f0424303ef4f94a65e35764cc9c4 (patch)
tree50d1d140d937b48ec3f3b75431dd2b026ec2a137
parent2df1f092bc046025b5d404ea7a74bfcd42b49ff6 (diff)
parentd21d444426911d93c507a929a8223ebf63258954 (diff)
downloadframeworks_base-5ccdaa9a0354f0424303ef4f94a65e35764cc9c4.zip
frameworks_base-5ccdaa9a0354f0424303ef4f94a65e35764cc9c4.tar.gz
frameworks_base-5ccdaa9a0354f0424303ef4f94a65e35764cc9c4.tar.bz2
Merge "Stop using charAt for Signatures"
-rw-r--r--core/java/android/content/pm/Signature.java25
1 files changed, 16 insertions, 9 deletions
diff --git a/core/java/android/content/pm/Signature.java b/core/java/android/content/pm/Signature.java
index d4e5cc1..b32664e 100644
--- a/core/java/android/content/pm/Signature.java
+++ b/core/java/android/content/pm/Signature.java
@@ -45,16 +45,23 @@ public class Signature implements Parcelable {
* {@link #toChars} or {@link #toCharsString()}.
*/
public Signature(String text) {
- final int N = text.length()/2;
- byte[] sig = new byte[N];
- for (int i=0; i<N; i++) {
- char c = text.charAt(i*2);
- byte b = (byte)(
- (c >= 'a' ? (c - 'a' + 10) : (c - '0'))<<4);
- c = text.charAt(i*2 + 1);
- b |= (byte)(c >= 'a' ? (c - 'a' + 10) : (c - '0'));
- sig[i] = b;
+ final byte[] input = text.getBytes();
+ final int N = input.length;
+ final byte[] sig = new byte[N / 2];
+ int sigIndex = 0;
+
+ for (int i = 0; i < N;) {
+ int b;
+
+ final int hi = input[i++];
+ b = (hi >= 'a' ? (hi - 'a' + 10) : (hi - '0')) << 4;
+
+ final int lo = input[i++];
+ b |= (lo >= 'a' ? (lo - 'a' + 10) : (lo - '0')) & 0x0F;
+
+ sig[sigIndex++] = (byte) (b & 0xFF);
}
+
mSignature = sig;
}