summaryrefslogtreecommitdiffstats
path: root/auth
diff options
context:
space:
mode:
authorBob Lee <crazybob@google.com>2009-08-26 17:28:52 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2009-08-26 17:28:52 -0700
commitac6d8498cb1af9e45d5741e689176904e87180c5 (patch)
treee1efea1b30721b8731594ac9677683405b91135d /auth
parent142d526f8bf90fb9bb63c637beb5299f39791f55 (diff)
parent5bd2429e5d62e7885c717bda72e789f2649837be (diff)
downloadlibcore-ac6d8498cb1af9e45d5741e689176904e87180c5.zip
libcore-ac6d8498cb1af9e45d5741e689176904e87180c5.tar.gz
libcore-ac6d8498cb1af9e45d5741e689176904e87180c5.tar.bz2
am dfd0afbc: Each time we start an SSL session, we have to find the trust anchor. This used to be an O(N) operation. If the trust anchor we\'re looking for was close to N, finding it could take a couple seconds. This change makes the operation O(1).
Merge commit 'dfd0afbcb08b871e224a28ecb4ed427a7693545c' into eclair * commit 'dfd0afbcb08b871e224a28ecb4ed427a7693545c': Each time we start an SSL session, we have to find the trust anchor. This used to be an O(N) operation. If the trust anchor we're looking for was close to N, finding it could take a couple seconds. This change makes the operation O(1).
Diffstat (limited to 'auth')
-rw-r--r--auth/src/main/java/javax/security/auth/x500/X500Principal.java22
1 files changed, 20 insertions, 2 deletions
diff --git a/auth/src/main/java/javax/security/auth/x500/X500Principal.java b/auth/src/main/java/javax/security/auth/x500/X500Principal.java
index 41f3a6d..19254a0 100644
--- a/auth/src/main/java/javax/security/auth/x500/X500Principal.java
+++ b/auth/src/main/java/javax/security/auth/x500/X500Principal.java
@@ -139,6 +139,16 @@ public final class X500Principal implements Serializable, Principal {
}
}
+// BEGIN android-added
+ private transient String canonicalName;
+ private synchronized String getCanonicalName() {
+ if (canonicalName == null) {
+ canonicalName = dn.getName(CANONICAL);
+ }
+ return canonicalName;
+ }
+// END android-added
+
@Override
public boolean equals(Object o) {
if (this == o) {
@@ -148,7 +158,9 @@ public final class X500Principal implements Serializable, Principal {
return false;
}
X500Principal principal = (X500Principal) o;
- return dn.getName(CANONICAL).equals(principal.dn.getName(CANONICAL));
+// BEGIN android-changed
+ return getCanonicalName().equals(principal.getCanonicalName());
+// END android-changed
}
/**
@@ -194,13 +206,19 @@ public final class X500Principal implements Serializable, Principal {
* mentioned above
*/
public String getName(String format) {
+// BEGIN android-changed
+ if (CANONICAL.equals(format)) {
+ return getCanonicalName();
+ }
+
return dn.getName(format);
}
@Override
public int hashCode() {
- return dn.getName(CANONICAL).hashCode();
+ return getCanonicalName().hashCode();
}
+// END android-changed
@Override
public String toString() {