-
Enhancement
-
Resolution: Fixed
-
P3
-
8u60, 9
-
b84
Consider:
private void socketWrite(byte b[], int off, int len) throws IOException {
if (!VMJFR.socketWriteToken.isEnabled()) {
socketWrite(b, off, len);
return;
}
SocketWriteEvent event = new SocketWriteEvent(VMJFR.socketWriteToken);
int bytesWritten = -1;
try {
event.begin();
socketWrite(b, off, len);
bytesWritten = len;
} finally {
String hostString = impl.address.toString();
int delimiterIndex = hostString.lastIndexOf('/');
event.host = hostString.substring(0, delimiterIndex);
event.address = hostString.substring(delimiterIndex + 1);
event.port = impl.port;
event.bytesWritten = bytesWritten;
event.commit();
}
}
We can avoid the address.toString() and String manipulations if we check event.shouldWrite() before.
private void socketWrite(byte b[], int off, int len) throws IOException {
if (!VMJFR.socketWriteToken.isEnabled()) {
socketWrite(b, off, len);
return;
}
SocketWriteEvent event = new SocketWriteEvent(VMJFR.socketWriteToken);
int bytesWritten = -1;
try {
event.begin();
socketWrite(b, off, len);
bytesWritten = len;
} finally {
String hostString = impl.address.toString();
int delimiterIndex = hostString.lastIndexOf('/');
event.host = hostString.substring(0, delimiterIndex);
event.address = hostString.substring(delimiterIndex + 1);
event.port = impl.port;
event.bytesWritten = bytesWritten;
event.commit();
}
}
We can avoid the address.toString() and String manipulations if we check event.shouldWrite() before.
- relates to
-
JDK-8135326 Add API to check if event will be committed before writing all the data of the event
-
- Closed
-