提交 0837f2d1 authored 作者: Jacek Ławrynowicz's avatar Jacek Ławrynowicz

performance - use addAll instead of manually adding each element

上级 69a1a3fe
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
package org.h2.command.ddl; package org.h2.command.ddl;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
import org.h2.api.ErrorCode; import org.h2.api.ErrorCode;
import org.h2.command.CommandInterface; import org.h2.command.CommandInterface;
...@@ -340,9 +341,7 @@ public class AlterTableAddConstraint extends SchemaCommand { ...@@ -340,9 +341,7 @@ public class AlterTableAddConstraint extends SchemaCommand {
} }
Column[] indexCols = idx.getColumns(); Column[] indexCols = idx.getColumns();
HashSet<Column> indexColsSet = new HashSet<>(); HashSet<Column> indexColsSet = new HashSet<>();
for (Column c : indexCols) { Collections.addAll(indexColsSet, indexCols);
indexColsSet.add(c);
}
HashSet<Column> colsSet = new HashSet<>(); HashSet<Column> colsSet = new HashSet<>();
for (IndexColumn c : cols) { for (IndexColumn c : cols) {
colsSet.add(c.column); colsSet.add(c.column);
......
...@@ -1045,9 +1045,7 @@ public class MetaTable extends Table { ...@@ -1045,9 +1045,7 @@ public class MetaTable extends Table {
// database settings // database settings
ArrayList<String> settingNames = New.arrayList(); ArrayList<String> settingNames = New.arrayList();
HashMap<String, String> s = database.getSettings().getSettings(); HashMap<String, String> s = database.getSettings().getSettings();
for (String k : s.keySet()) { settingNames.addAll(s.keySet());
settingNames.add(k);
}
Collections.sort(settingNames); Collections.sort(settingNames);
for (String k : settingNames) { for (String k : settingNames) {
add(rows, k, s.get(k)); add(rows, k, s.get(k));
......
...@@ -371,9 +371,7 @@ public abstract class Table extends SchemaObjectBase { ...@@ -371,9 +371,7 @@ public abstract class Table extends SchemaObjectBase {
return; return;
} }
if (sequences != null) { if (sequences != null) {
for (Sequence s : sequences) { dependencies.addAll(sequences);
dependencies.add(s);
}
} }
ExpressionVisitor visitor = ExpressionVisitor.getDependenciesVisitor( ExpressionVisitor visitor = ExpressionVisitor.getDependenciesVisitor(
dependencies); dependencies);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论