Fix from audit : improve ICSBufferedReader performance, reuse StringBuilder

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@285 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2009-01-09 22:41:10 +00:00
parent 780e6fb827
commit ec59882589
4 changed files with 18 additions and 7 deletions

View File

@ -731,7 +731,7 @@ public class CaldavConnection extends AbstractConnection {
}
protected class CaldavRequest {
protected static class CaldavRequest {
protected HashSet<String> properties = new HashSet<String>();
protected HashSet<String> hrefs;
protected boolean isMultiGet;

View File

@ -10,6 +10,7 @@ import java.io.IOException;
*/
public class ICSBufferedReader extends BufferedReader {
protected String nextLine;
protected StringBuilder currentLine = new StringBuilder(75);
public ICSBufferedReader(Reader in, int sz) throws IOException {
super(in, sz);
@ -23,12 +24,17 @@ public class ICSBufferedReader extends BufferedReader {
@Override
public String readLine() throws IOException {
String currentLine = nextLine;
nextLine = super.readLine();
while (nextLine != null && nextLine.charAt(0) == ' ') {
currentLine += nextLine.substring(1);
if (nextLine == null) {
return null;
} else {
currentLine.setLength(0);
currentLine.append(nextLine);
nextLine = super.readLine();
while (nextLine != null && nextLine.charAt(0) == ' ') {
currentLine.append(nextLine.substring(1));
nextLine = super.readLine();
}
return currentLine.toString();
}
return currentLine;
}
}

View File

@ -135,7 +135,9 @@ public class ImapConnection extends AbstractConnection {
}
/**
* Decode SMTP credentials
* Decode IMAP credentials
* @param tokens tokens
* @throws java.io.IOException on error
*/
protected void parseCredentials(StringTokenizer tokens) throws IOException {
if (tokens.hasMoreTokens()) {

View File

@ -16,6 +16,9 @@ public class ImapServer extends AbstractServer {
/**
* Create a ServerSocket to listen for connections.
* Start the thread.
*
* @param port imap listen port, 143 if not defined (0)
* @throws java.io.IOException on error
*/
public ImapServer(int port) throws IOException {
super("ImapServer", port, ImapServer.DEFAULT_PORT);