mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-27 11:42:16 -05:00
Merge pull request #55 from andrewgaul/stringbuilder
Prefer StringBuilder over StringBuffer
This commit is contained in:
commit
2e2428b093
@ -380,7 +380,7 @@ public class Account implements BaseAccount {
|
||||
}
|
||||
|
||||
private String combineUuids(String[] uuids) {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0, length = uuids.length; i < length; i++) {
|
||||
if (sb.length() > 0) {
|
||||
sb.append(',');
|
||||
|
@ -727,7 +727,7 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
|
||||
private boolean setRecipients(TextView view, List<String> recipients) {
|
||||
boolean recipientAdded = false;
|
||||
if (recipients != null) {
|
||||
StringBuffer addressList = new StringBuffer();
|
||||
StringBuilder addressList = new StringBuilder();
|
||||
for (String recipient : recipients) {
|
||||
addressList.append(recipient);
|
||||
addressList.append(", ");
|
||||
@ -1964,7 +1964,7 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
|
||||
mInReplyTo = message.getMessageId();
|
||||
|
||||
if (message.getReferences() != null && message.getReferences().length > 0) {
|
||||
StringBuffer buffy = new StringBuffer();
|
||||
StringBuilder buffy = new StringBuilder();
|
||||
for (int i = 0; i < message.getReferences().length; i++)
|
||||
buffy.append(message.getReferences()[i]);
|
||||
|
||||
|
@ -243,7 +243,7 @@ public class AccountSetupCheckSettings extends K9Activity implements OnClickList
|
||||
}
|
||||
|
||||
mProgressBar.setIndeterminate(false);
|
||||
StringBuffer chainInfo = new StringBuffer(100);
|
||||
StringBuilder chainInfo = new StringBuilder(100);
|
||||
MessageDigest sha1 = null;
|
||||
try {
|
||||
sha1 = MessageDigest.getInstance("SHA-1");
|
||||
@ -265,7 +265,7 @@ public class AccountSetupCheckSettings extends K9Activity implements OnClickList
|
||||
if (subjectAlternativeNames != null) {
|
||||
// The list of SubjectAltNames may be very long
|
||||
//TODO: localize this string
|
||||
StringBuffer altNamesText = new StringBuffer("Subject has " + subjectAlternativeNames.size() + " alternative names\n");
|
||||
StringBuilder altNamesText = new StringBuilder("Subject has " + subjectAlternativeNames.size() + " alternative names\n");
|
||||
|
||||
// we need these for matching
|
||||
String storeURIHost = (Uri.parse(mAccount.getStoreUri())).getHost();
|
||||
|
@ -38,7 +38,7 @@ public class Utility {
|
||||
|
||||
public static String readInputStream(InputStream in, String encoding) throws IOException {
|
||||
InputStreamReader reader = new InputStreamReader(in, encoding);
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
int count;
|
||||
char[] buf = new char[512];
|
||||
while ((count = reader.read(buf)) != -1) {
|
||||
|
@ -179,7 +179,7 @@ public class Address {
|
||||
if (addresses == null) {
|
||||
return null;
|
||||
}
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < addresses.length; i++) {
|
||||
sb.append(addresses[i].toString());
|
||||
if (i < addresses.length - 1) {
|
||||
@ -201,7 +201,7 @@ public class Address {
|
||||
if (addresses == null) {
|
||||
return null;
|
||||
}
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < addresses.length; i++) {
|
||||
sb.append(addresses[i].toEncodedString());
|
||||
if (i < addresses.length - 1) {
|
||||
|
@ -58,7 +58,7 @@ public class DecoderUtil {
|
||||
/*
|
||||
* Replace _ with =20
|
||||
*/
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < encodedWord.length(); i++) {
|
||||
char c = encodedWord.charAt(i);
|
||||
if (c == '_') {
|
||||
|
@ -530,7 +530,7 @@ public class MimeMessage extends Message {
|
||||
|
||||
public void epilogue(InputStream is) throws IOException {
|
||||
expect(MimeMultipart.class);
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
int b;
|
||||
while ((b = is.read()) != -1) {
|
||||
sb.append((char)b);
|
||||
@ -540,7 +540,7 @@ public class MimeMessage extends Message {
|
||||
|
||||
public void preamble(InputStream is) throws IOException {
|
||||
expect(MimeMultipart.class);
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
int b;
|
||||
while ((b = is.read()) != -1) {
|
||||
sb.append((char)b);
|
||||
|
@ -37,7 +37,7 @@ public class MimeMultipart extends Multipart {
|
||||
}
|
||||
|
||||
public String generateBoundary() {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("----");
|
||||
for (int i = 0; i < 30; i++) {
|
||||
sb.append(Integer.toString((int)(Math.random() * 35), 36));
|
||||
|
@ -281,7 +281,7 @@ public class ImapResponseParser {
|
||||
private String parseQuoted() throws IOException {
|
||||
expect('"');
|
||||
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
int ch;
|
||||
boolean escape = false;
|
||||
while ((ch = mIn.read()) != -1) {
|
||||
@ -299,7 +299,7 @@ public class ImapResponseParser {
|
||||
}
|
||||
|
||||
private String readStringUntil(char end) throws IOException {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
int ch;
|
||||
while ((ch = mIn.read()) != -1) {
|
||||
if (ch == end) {
|
||||
@ -471,7 +471,7 @@ public class ImapResponseParser {
|
||||
|
||||
public String getAlertText() {
|
||||
if (size() > 1 && equalsIgnoreCase("[ALERT]", get(1))) {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 2, count = size(); i < count; i++) {
|
||||
sb.append(get(i).toString());
|
||||
sb.append(' ');
|
||||
|
@ -1417,7 +1417,7 @@ public class ImapStore extends Store {
|
||||
// String key = (String)keyObj;
|
||||
// if ("ALERT".equalsIgnoreCase(key))
|
||||
// {
|
||||
// StringBuffer sb = new StringBuffer();
|
||||
// StringBuilder sb = new StringBuilder();
|
||||
// for (int i = 2, count = response.size(); i < count; i++) {
|
||||
// sb.append(response.get(i).toString());
|
||||
// sb.append(' ');
|
||||
|
@ -844,7 +844,7 @@ public class LocalStore extends Store implements Serializable {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(command);
|
||||
sb.append(": ");
|
||||
for (String argument : arguments) {
|
||||
@ -1788,7 +1788,7 @@ public class LocalStore extends Store implements Serializable {
|
||||
try {
|
||||
Map<Long, LocalMessage> popMessages = new HashMap<Long, LocalMessage>();
|
||||
List<String> ids = new ArrayList<String>();
|
||||
StringBuffer questions = new StringBuffer();
|
||||
StringBuilder questions = new StringBuilder();
|
||||
|
||||
for (int i = 0; i < messages.size(); i++) {
|
||||
if (i != 0) {
|
||||
@ -2097,15 +2097,15 @@ public class LocalStore extends Store implements Serializable {
|
||||
ArrayList<Part> attachments = new ArrayList<Part>();
|
||||
MimeUtility.collectParts(message, viewables, attachments);
|
||||
|
||||
StringBuffer sbHtml = new StringBuffer();
|
||||
StringBuffer sbText = new StringBuffer();
|
||||
StringBuilder sbHtml = new StringBuilder();
|
||||
StringBuilder sbText = new StringBuilder();
|
||||
for (Part viewable : viewables) {
|
||||
try {
|
||||
String text = MimeUtility.getTextFromPart(viewable);
|
||||
|
||||
/*
|
||||
* Small hack to make sure the string "null" doesn't end up
|
||||
* in one of the StringBuffers.
|
||||
* in one of the StringBuilders.
|
||||
*/
|
||||
if (text == null) {
|
||||
text = "";
|
||||
@ -2210,8 +2210,8 @@ public class LocalStore extends Store implements Serializable {
|
||||
|
||||
MimeUtility.collectParts(message, viewables, attachments);
|
||||
|
||||
StringBuffer sbHtml = new StringBuffer();
|
||||
StringBuffer sbText = new StringBuffer();
|
||||
StringBuilder sbHtml = new StringBuilder();
|
||||
StringBuilder sbText = new StringBuilder();
|
||||
for (int i = 0, count = viewables.size(); i < count; i++) {
|
||||
Part viewable = viewables.get(i);
|
||||
try {
|
||||
@ -2219,7 +2219,7 @@ public class LocalStore extends Store implements Serializable {
|
||||
|
||||
/*
|
||||
* Small hack to make sure the string "null" doesn't end up
|
||||
* in one of the StringBuffers.
|
||||
* in one of the StringBuilders.
|
||||
*/
|
||||
if (text == null) {
|
||||
text = "";
|
||||
|
@ -825,7 +825,7 @@ public class Pop3Store extends Store {
|
||||
}
|
||||
|
||||
private String readLine() throws IOException {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
int d = mIn.read();
|
||||
if (d == -1) {
|
||||
throw new IOException("End of stream reached while trying to read line.");
|
||||
|
@ -398,7 +398,7 @@ public class WebDavStore extends Store {
|
||||
}
|
||||
|
||||
private String getSpecialFoldersList() {
|
||||
StringBuffer buffer = new StringBuffer(200);
|
||||
StringBuilder buffer = new StringBuilder(200);
|
||||
buffer.append("<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>");
|
||||
buffer.append("<propfind xmlns=\"DAV:\">");
|
||||
buffer.append("<prop>");
|
||||
@ -421,7 +421,7 @@ public class WebDavStore extends Store {
|
||||
* WebDAV XML Request body retrieval functions
|
||||
*/
|
||||
private String getFolderListXml() {
|
||||
StringBuffer buffer = new StringBuffer(200);
|
||||
StringBuilder buffer = new StringBuilder(200);
|
||||
buffer.append("<?xml version='1.0' ?>");
|
||||
buffer.append("<a:searchrequest xmlns:a='DAV:'><a:sql>\r\n");
|
||||
buffer.append("SELECT \"DAV:uid\", \"DAV:ishidden\"\r\n");
|
||||
@ -432,7 +432,7 @@ public class WebDavStore extends Store {
|
||||
}
|
||||
|
||||
private String getMessageCountXml(String messageState) {
|
||||
StringBuffer buffer = new StringBuffer(200);
|
||||
StringBuilder buffer = new StringBuilder(200);
|
||||
buffer.append("<?xml version='1.0' ?>");
|
||||
buffer.append("<a:searchrequest xmlns:a='DAV:'><a:sql>\r\n");
|
||||
buffer.append("SELECT \"DAV:visiblecount\"\r\n");
|
||||
@ -445,7 +445,7 @@ public class WebDavStore extends Store {
|
||||
}
|
||||
|
||||
private String getMessageEnvelopeXml(String[] uids) {
|
||||
StringBuffer buffer = new StringBuffer(200);
|
||||
StringBuilder buffer = new StringBuilder(200);
|
||||
buffer.append("<?xml version='1.0' ?>");
|
||||
buffer.append("<a:searchrequest xmlns:a='DAV:'><a:sql>\r\n");
|
||||
buffer.append("SELECT \"DAV:uid\", \"DAV:getcontentlength\",");
|
||||
@ -475,7 +475,7 @@ public class WebDavStore extends Store {
|
||||
}
|
||||
|
||||
private String getMessagesXml() {
|
||||
StringBuffer buffer = new StringBuffer(200);
|
||||
StringBuilder buffer = new StringBuilder(200);
|
||||
buffer.append("<?xml version='1.0' ?>");
|
||||
buffer.append("<a:searchrequest xmlns:a='DAV:'><a:sql>\r\n");
|
||||
buffer.append("SELECT \"DAV:uid\"\r\n");
|
||||
@ -486,7 +486,7 @@ public class WebDavStore extends Store {
|
||||
}
|
||||
|
||||
private String getMessageUrlsXml(String[] uids) {
|
||||
StringBuffer buffer = new StringBuffer(600);
|
||||
StringBuilder buffer = new StringBuilder(600);
|
||||
buffer.append("<?xml version='1.0' ?>");
|
||||
buffer.append("<a:searchrequest xmlns:a='DAV:'><a:sql>\r\n");
|
||||
buffer.append("SELECT \"urn:schemas:httpmail:read\", \"DAV:uid\"\r\n");
|
||||
@ -510,7 +510,7 @@ public class WebDavStore extends Store {
|
||||
throw new MessagingException("Attempt to get flags on 0 length array for uids");
|
||||
}
|
||||
|
||||
StringBuffer buffer = new StringBuffer(200);
|
||||
StringBuilder buffer = new StringBuilder(200);
|
||||
buffer.append("<?xml version='1.0' ?>");
|
||||
buffer.append("<a:searchrequest xmlns:a='DAV:'><a:sql>\r\n");
|
||||
buffer.append("SELECT \"urn:schemas:httpmail:read\", \"DAV:uid\"\r\n");
|
||||
@ -529,7 +529,7 @@ public class WebDavStore extends Store {
|
||||
}
|
||||
|
||||
private String getMarkMessagesReadXml(String[] urls, boolean read) {
|
||||
StringBuffer buffer = new StringBuffer(600);
|
||||
StringBuilder buffer = new StringBuilder(600);
|
||||
buffer.append("<?xml version='1.0' ?>\r\n");
|
||||
buffer.append("<a:propertyupdate xmlns:a='DAV:' xmlns:b='urn:schemas:httpmail:'>\r\n");
|
||||
buffer.append("<a:target>\r\n");
|
||||
@ -553,7 +553,7 @@ public class WebDavStore extends Store {
|
||||
private String getMoveOrCopyMessagesReadXml(String[] urls, boolean isMove) {
|
||||
|
||||
String action = (isMove ? "move" : "copy");
|
||||
StringBuffer buffer = new StringBuffer(600);
|
||||
StringBuilder buffer = new StringBuilder(600);
|
||||
buffer.append("<?xml version='1.0' ?>\r\n");
|
||||
buffer.append("<a:").append(action).append(" xmlns:a='DAV:' xmlns:b='urn:schemas:httpmail:'>\r\n");
|
||||
buffer.append("<a:target>\r\n");
|
||||
@ -1488,7 +1488,7 @@ public class WebDavStore extends Store {
|
||||
|
||||
if (entity != null) {
|
||||
InputStream istream = null;
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
String tempText = "";
|
||||
String resultText = "";
|
||||
BufferedReader reader;
|
||||
|
@ -429,7 +429,7 @@ public class SmtpTransport extends Transport {
|
||||
}
|
||||
|
||||
private String readLine() throws IOException {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
int d;
|
||||
while ((d = mIn.read()) != -1) {
|
||||
if (((char)d) == '\r') {
|
||||
|
Loading…
Reference in New Issue
Block a user