* Move almost all uses of StringBuffer to StringBuilder,
for efficiency (thanks Arsene for the suggestion)
This commit is contained in:
@ -899,7 +899,7 @@ public class Connection {
|
||||
if (_log.shouldLog(Log.WARN))
|
||||
_log.warn("Closing connection due to inactivity");
|
||||
if (_log.shouldLog(Log.DEBUG)) {
|
||||
StringBuffer buf = new StringBuffer(128);
|
||||
StringBuilder buf = new StringBuilder(128);
|
||||
buf.append("last sent was: ").append(_context.clock().now() - _lastSendTime);
|
||||
buf.append("ms ago, last received was: ").append(_context.clock().now()-_lastReceivedOn);
|
||||
buf.append("ms ago, inactivity timeout is: ").append(_options.getInactivityTimeout());
|
||||
@ -934,7 +934,7 @@ public class Connection {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer buf = new StringBuffer(128);
|
||||
StringBuilder buf = new StringBuilder(128);
|
||||
buf.append("[Connection ");
|
||||
if (_receiveStreamId > 0)
|
||||
buf.append(Packet.toId(_receiveStreamId));
|
||||
|
@ -475,7 +475,7 @@ public class ConnectionOptions extends I2PSocketOptionsImpl {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer buf = new StringBuffer(128);
|
||||
StringBuilder buf = new StringBuilder(128);
|
||||
buf.append("conDelay=").append(_connectDelay);
|
||||
buf.append(" maxSize=").append(_maxMessageSize);
|
||||
buf.append(" rtt=").append(_rtt);
|
||||
|
@ -174,7 +174,7 @@ public class MessageInputStream extends InputStream {
|
||||
public void closeReceived() {
|
||||
synchronized (_dataLock) {
|
||||
if (_log.shouldLog(Log.DEBUG)) {
|
||||
StringBuffer buf = new StringBuffer(128);
|
||||
StringBuilder buf = new StringBuilder(128);
|
||||
buf.append("Close received, ready bytes: ");
|
||||
long available = 0;
|
||||
for (int i = 0; i < _readyDataBlocks.size(); i++)
|
||||
|
@ -598,12 +598,12 @@ public class Packet {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer str = formatAsString();
|
||||
StringBuilder str = formatAsString();
|
||||
return str.toString();
|
||||
}
|
||||
|
||||
protected StringBuffer formatAsString() {
|
||||
StringBuffer buf = new StringBuffer(64);
|
||||
protected StringBuilder formatAsString() {
|
||||
StringBuilder buf = new StringBuilder(64);
|
||||
buf.append(toId(_sendStreamId));
|
||||
//buf.append("<-->");
|
||||
buf.append(toId(_receiveStreamId)).append(": #").append(_sequenceNum);
|
||||
@ -629,7 +629,7 @@ public class Packet {
|
||||
}
|
||||
|
||||
private final String toFlagString() {
|
||||
StringBuffer buf = new StringBuffer(32);
|
||||
StringBuilder buf = new StringBuilder(32);
|
||||
if (isFlagSet(FLAG_CLOSE)) buf.append(" CLOSE");
|
||||
if (isFlagSet(FLAG_DELAY_REQUESTED)) buf.append(" DELAY ").append(_optionDelay);
|
||||
if (isFlagSet(FLAG_ECHO)) buf.append(" ECHO");
|
||||
|
@ -112,7 +112,7 @@ public class PacketHandler {
|
||||
private static final SimpleDateFormat _fmt = new SimpleDateFormat("HH:mm:ss.SSS");
|
||||
void displayPacket(Packet packet, String prefix, String suffix) {
|
||||
if (!_log.shouldLog(Log.INFO)) return;
|
||||
StringBuffer buf = new StringBuffer(256);
|
||||
StringBuilder buf = new StringBuilder(256);
|
||||
synchronized (_fmt) {
|
||||
buf.append(_fmt.format(new Date()));
|
||||
}
|
||||
@ -198,7 +198,7 @@ public class PacketHandler {
|
||||
// someone is sending us a packet on the wrong stream
|
||||
if (_log.shouldLog(Log.ERROR)) {
|
||||
Set cons = _manager.listConnections();
|
||||
StringBuffer buf = new StringBuffer(512);
|
||||
StringBuilder buf = new StringBuilder(512);
|
||||
buf.append("Received a packet on the wrong stream: ");
|
||||
buf.append(packet);
|
||||
buf.append(" connection: ");
|
||||
@ -275,7 +275,7 @@ public class PacketHandler {
|
||||
_log.warn("Packet belongs to no other cons, putting on the syn queue: " + packet);
|
||||
}
|
||||
if (_log.shouldLog(Log.DEBUG)) {
|
||||
StringBuffer buf = new StringBuffer(128);
|
||||
StringBuilder buf = new StringBuilder(128);
|
||||
Set cons = _manager.listConnections();
|
||||
for (Iterator iter = cons.iterator(); iter.hasNext(); ) {
|
||||
Connection con = (Connection)iter.next();
|
||||
|
@ -133,8 +133,8 @@ public class PacketLocal extends Packet implements MessageOutputStream.WriteStat
|
||||
public void setResendPacketEvent(SimpleTimer2.TimedEvent evt) { _resendEvent = evt; }
|
||||
|
||||
@Override
|
||||
public StringBuffer formatAsString() {
|
||||
StringBuffer buf = super.formatAsString();
|
||||
public StringBuilder formatAsString() {
|
||||
StringBuilder buf = super.formatAsString();
|
||||
|
||||
Connection con = _connection;
|
||||
if (con != null)
|
||||
|
Reference in New Issue
Block a user