From 9b27aba2ba715aa9e37dd0b5c3f87dd48cdb8fee Mon Sep 17 00:00:00 2001 From: Andrew Gaul Date: Thu, 6 Oct 2011 09:20:11 -0700 Subject: [PATCH] Avoid concatenation in StringBuilder append --- src/com/fsck/k9/activity/Accounts.java | 2 +- .../activity/setup/AccountSetupCheckSettings.java | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/com/fsck/k9/activity/Accounts.java b/src/com/fsck/k9/activity/Accounts.java index 420ac7d78..0f76e2416 100644 --- a/src/com/fsck/k9/activity/Accounts.java +++ b/src/com/fsck/k9/activity/Accounts.java @@ -745,7 +745,7 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC StringBuilder libs = new StringBuilder().append(""); diff --git a/src/com/fsck/k9/activity/setup/AccountSetupCheckSettings.java b/src/com/fsck/k9/activity/setup/AccountSetupCheckSettings.java index d9e1e11e2..dad534767 100644 --- a/src/com/fsck/k9/activity/setup/AccountSetupCheckSettings.java +++ b/src/com/fsck/k9/activity/setup/AccountSetupCheckSettings.java @@ -253,8 +253,8 @@ public class AccountSetupCheckSettings extends K9Activity implements OnClickList for (int i = 0; i < chain.length; i++) { // display certificate chain information //TODO: localize this strings - chainInfo.append("Certificate chain[" + i + "]:\n"); - chainInfo.append("Subject: " + chain[i].getSubjectDN().toString() + "\n"); + chainInfo.append("Certificate chain[").append(i).append("]:\n"); + chainInfo.append("Subject: ").append(chain[i].getSubjectDN().toString()).append("\n"); // display SubjectAltNames too // (the user may be mislead into mistrusting a certificate @@ -265,7 +265,8 @@ public class AccountSetupCheckSettings extends K9Activity implements OnClickList if (subjectAlternativeNames != null) { // The list of SubjectAltNames may be very long //TODO: localize this string - StringBuilder altNamesText = new StringBuilder("Subject has " + subjectAlternativeNames.size() + " alternative names\n"); + StringBuilder altNamesText = new StringBuilder(); + altNamesText.append("Subject has ").append(subjectAlternativeNames.size()).append(" alternative names\n"); // we need these for matching String storeURIHost = (Uri.parse(mAccount.getStoreUri())).getHost(); @@ -309,11 +310,11 @@ public class AccountSetupCheckSettings extends K9Activity implements OnClickList // display them if (name.equalsIgnoreCase(storeURIHost) || name.equalsIgnoreCase(transportURIHost)) { //TODO: localize this string - altNamesText.append("Subject(alt): " + name + ",...\n"); + altNamesText.append("Subject(alt): ").append(name).append(",...\n"); } else if (name.startsWith("*.")) { if (storeURIHost.endsWith(name.substring(2)) || transportURIHost.endsWith(name.substring(2))) { //TODO: localize this string - altNamesText.append("Subject(alt): " + name + ",...\n"); + altNamesText.append("Subject(alt): ").append(name).append(",...\n"); } } } @@ -324,12 +325,12 @@ public class AccountSetupCheckSettings extends K9Activity implements OnClickList Log.w(K9.LOG_TAG, "cannot display SubjectAltNames in dialog", e1); } - chainInfo.append("Issuer: " + chain[i].getIssuerDN().toString() + "\n"); + chainInfo.append("Issuer: ").append(chain[i].getIssuerDN().toString()).append("\n"); if (sha1 != null) { sha1.reset(); try { char[] sha1sum = Hex.encodeHex(sha1.digest(chain[i].getEncoded())); - chainInfo.append("Fingerprint (SHA-1): " + new String(sha1sum) + "\n"); + chainInfo.append("Fingerprint (SHA-1): ").append(new String(sha1sum)).append("\n"); } catch (CertificateEncodingException e) { Log.e(K9.LOG_TAG, "Error while encoding certificate", e); }