= performance improve

- using bulk operation instead of iteration if possible
  - terminate loop after condition is met
This commit is contained in:
zavakid
2020-09-18 00:51:10 +08:00
parent e7de8289cd
commit 435db30b7b
2 changed files with 2 additions and 3 deletions

View File

@@ -191,9 +191,7 @@ public class DatabaseTableMeta implements TableMetaTSDB {
try { try {
ResultSetPacket packet = connection.query("show databases"); ResultSetPacket packet = connection.query("show databases");
List<String> schemas = new ArrayList<>(); List<String> schemas = new ArrayList<>();
for (String schema : packet.getFieldValues()) { schemas.addAll(packet.getFieldValues());
schemas.add(schema);
}
for (String schema : schemas) { for (String schema : schemas) {
// filter views // filter views

View File

@@ -20,6 +20,7 @@ public class HeartBeatEntryEventHandler extends AbstractCanalEventDownStreamHand
for (Event event : events) { for (Event event : events) {
if (event.getEntryType() == EntryType.HEARTBEAT) { if (event.getEntryType() == EntryType.HEARTBEAT) {
existHeartBeat = true; existHeartBeat = true;
break;
} }
} }