mirror of
https://github.com/alibaba/canal.git
synced 2026-11-04 00:30:15 +08:00
= code cleanup
- for loop replaceable with enhanced 'for' loop - using diamond in generic type - collapse try catch exception - using try-with-resource - using List#sort instead of Collections#sort - replaced lambda with method reference - using native compare method to compare numbers - using switch instead of if for in ESSyncUtil
This commit is contained in:
@@ -161,8 +161,8 @@ public class SessionHandler extends SimpleChannelHandler {
|
||||
messageSize += com.google.protobuf.CodedOutputStream.computeInt64Size(1, message.getId());
|
||||
|
||||
int dataSize = 0;
|
||||
for (int i = 0; i < rowEntries.size(); i++) {
|
||||
dataSize += com.google.protobuf.CodedOutputStream.computeBytesSizeNoTag(rowEntries.get(i));
|
||||
for (ByteString rowEntry : rowEntries) {
|
||||
dataSize += CodedOutputStream.computeBytesSizeNoTag(rowEntry);
|
||||
}
|
||||
messageSize += dataSize;
|
||||
messageSize += 1 * rowEntries.size();
|
||||
@@ -194,8 +194,8 @@ public class SessionHandler extends SimpleChannelHandler {
|
||||
output.writeRawVarint32(messageSize);
|
||||
// message
|
||||
output.writeInt64(1, message.getId());
|
||||
for (int i = 0; i < rowEntries.size(); i++) {
|
||||
output.writeBytes(2, rowEntries.get(i));
|
||||
for (ByteString rowEntry : rowEntries) {
|
||||
output.writeBytes(2, rowEntry);
|
||||
}
|
||||
output.checkNoSpaceLeft();
|
||||
NettyUtils.write(ctx.getChannel(), body, new ChannelFutureAggregator(get.getDestination(),
|
||||
|
||||
@@ -63,8 +63,8 @@ public class ProtocolTest {
|
||||
messageSize += com.google.protobuf.CodedOutputStream.computeInt64Size(1, message.getId());
|
||||
|
||||
int dataSize = 0;
|
||||
for (int i = 0; i < rowEntries.size(); i++) {
|
||||
dataSize += com.google.protobuf.CodedOutputStream.computeBytesSizeNoTag(rowEntries.get(i));
|
||||
for (ByteString rowEntry : rowEntries) {
|
||||
dataSize += CodedOutputStream.computeBytesSizeNoTag(rowEntry);
|
||||
}
|
||||
messageSize += dataSize;
|
||||
messageSize += 1 * rowEntries.size();
|
||||
@@ -82,8 +82,8 @@ public class ProtocolTest {
|
||||
output.writeRawVarint32(messageSize);
|
||||
// message
|
||||
output.writeInt64(1, message.getId());
|
||||
for (int i = 0; i < rowEntries.size(); i++) {
|
||||
output.writeBytes(2, rowEntries.get(i));
|
||||
for (ByteString rowEntry : rowEntries) {
|
||||
output.writeBytes(2, rowEntry);
|
||||
}
|
||||
output.checkNoSpaceLeft();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user