1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-12-24 08:38:51 -05:00

Prefer StringBuilder.append over String.concat

Addresses FindBugs complaints.
This commit is contained in:
Andrew Gaul 2011-10-31 21:56:32 -07:00
parent 976761e0e5
commit cb14cd9d78
2 changed files with 20 additions and 19 deletions

View File

@ -1366,7 +1366,7 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
} }
if (mEncryptCheckbox.isChecked() && !mPgpData.hasEncryptionKeys()) { if (mEncryptCheckbox.isChecked() && !mPgpData.hasEncryptionKeys()) {
// key selection before encryption // key selection before encryption
String emails = ""; StringBuilder emails = new StringBuilder();
Address[][] addresses = new Address[][] { getAddresses(mToView), Address[][] addresses = new Address[][] { getAddresses(mToView),
getAddresses(mCcView), getAddresses(mCcView),
getAddresses(mBccView) getAddresses(mBccView)
@ -1374,18 +1374,18 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
for (Address[] addressArray : addresses) { for (Address[] addressArray : addresses) {
for (Address address : addressArray) { for (Address address : addressArray) {
if (emails.length() != 0) { if (emails.length() != 0) {
emails += ","; emails.append(',');
} }
emails += address.getAddress(); emails.append(address.getAddress());
} }
} }
if (emails.length() != 0) { if (emails.length() != 0) {
emails += ","; emails.append(',');
} }
emails += mIdentity.getEmail(); emails.append(mIdentity.getEmail());
mPreventDraftSaving = true; mPreventDraftSaving = true;
if (!mAccount.getCryptoProvider().selectEncryptionKeys(MessageCompose.this, emails, mPgpData)) { if (!mAccount.getCryptoProvider().selectEncryptionKeys(MessageCompose.this, emails.toString(), mPgpData)) {
mPreventDraftSaving = false; mPreventDraftSaving = false;
} }
return; return;

View File

@ -1514,7 +1514,8 @@ public class ImapStore extends Store {
/* /*
* Set the content type with as much information as we know right now. * Set the content type with as much information as we know right now.
*/ */
String contentType = String.format("%s", mimeType); StringBuilder contentType = new StringBuilder();
contentType.append(mimeType);
if (bodyParams != null) { if (bodyParams != null) {
/* /*
@ -1522,13 +1523,13 @@ public class ImapStore extends Store {
* of them. * of them.
*/ */
for (int i = 0, count = bodyParams.size(); i < count; i += 2) { for (int i = 0, count = bodyParams.size(); i < count; i += 2) {
contentType += String.format(";\n %s=\"%s\"", contentType.append(String.format(";\n %s=\"%s\"",
bodyParams.getString(i), bodyParams.getString(i),
bodyParams.getString(i + 1)); bodyParams.getString(i + 1)));
} }
} }
part.setHeader(MimeHeader.HEADER_CONTENT_TYPE, contentType); part.setHeader(MimeHeader.HEADER_CONTENT_TYPE, contentType.toString());
// Extension items // Extension items
ImapList bodyDisposition = null; ImapList bodyDisposition = null;
@ -1542,11 +1543,11 @@ public class ImapStore extends Store {
bodyDisposition = bs.getList(8); bodyDisposition = bs.getList(8);
} }
String contentDisposition = ""; StringBuilder contentDisposition = new StringBuilder();
if (bodyDisposition != null && bodyDisposition.size() > 0) { if (bodyDisposition != null && bodyDisposition.size() > 0) {
if (!"NIL".equalsIgnoreCase(bodyDisposition.getString(0))) { if (!"NIL".equalsIgnoreCase(bodyDisposition.getString(0))) {
contentDisposition = bodyDisposition.getString(0).toLowerCase(Locale.US); contentDisposition.append(bodyDisposition.getString(0).toLowerCase(Locale.US));
} }
if ((bodyDisposition.size() > 1) if ((bodyDisposition.size() > 1)
@ -1557,22 +1558,22 @@ public class ImapStore extends Store {
* about the attachment out. * about the attachment out.
*/ */
for (int i = 0, count = bodyDispositionParams.size(); i < count; i += 2) { for (int i = 0, count = bodyDispositionParams.size(); i < count; i += 2) {
contentDisposition += String.format(";\n %s=\"%s\"", contentDisposition.append(String.format(";\n %s=\"%s\"",
bodyDispositionParams.getString(i).toLowerCase(Locale.US), bodyDispositionParams.getString(i).toLowerCase(Locale.US),
bodyDispositionParams.getString(i + 1)); bodyDispositionParams.getString(i + 1)));
} }
} }
} }
if (MimeUtility.getHeaderParameter(contentDisposition, "size") == null) { if (MimeUtility.getHeaderParameter(contentDisposition.toString(), "size") == null) {
contentDisposition += String.format(";\n size=%d", size); contentDisposition.append(String.format(";\n size=%d", size));
} }
/* /*
* Set the content disposition containing at least the size. Attachment * Set the content disposition containing at least the size. Attachment
* handling code will use this down the road. * handling code will use this down the road.
*/ */
part.setHeader(MimeHeader.HEADER_CONTENT_DISPOSITION, contentDisposition); part.setHeader(MimeHeader.HEADER_CONTENT_DISPOSITION, contentDisposition.toString());
/* /*