提交 760c0ae8 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Use new ArrayList(Collection)

上级 79b5e027
...@@ -43,8 +43,7 @@ public class QueryStatisticsData { ...@@ -43,8 +43,7 @@ public class QueryStatisticsData {
public synchronized List<QueryEntry> getQueries() { public synchronized List<QueryEntry> getQueries() {
// return a copy of the map so we don't have to // return a copy of the map so we don't have to
// worry about external synchronization // worry about external synchronization
ArrayList<QueryEntry> list = new ArrayList<>(); ArrayList<QueryEntry> list = new ArrayList<>(map.values());
list.addAll(map.values());
// only return the newest 100 entries // only return the newest 100 entries
Collections.sort(list, QUERY_ENTRY_COMPARATOR); Collections.sort(list, QUERY_ENTRY_COMPARATOR);
return list.subList(0, Math.min(list.size(), maxQueryEntries)); return list.subList(0, Math.min(list.size(), maxQueryEntries));
...@@ -71,8 +70,7 @@ public class QueryStatisticsData { ...@@ -71,8 +70,7 @@ public class QueryStatisticsData {
// Test against 1.5 x max-size so we don't do this too often // Test against 1.5 x max-size so we don't do this too often
if (map.size() > maxQueryEntries * 1.5f) { if (map.size() > maxQueryEntries * 1.5f) {
// Sort the entries by age // Sort the entries by age
ArrayList<QueryEntry> list = new ArrayList<>(); ArrayList<QueryEntry> list = new ArrayList<>(map.values());
list.addAll(map.values());
Collections.sort(list, QUERY_ENTRY_COMPARATOR); Collections.sort(list, QUERY_ENTRY_COMPARATOR);
// Create a set of the oldest 1/3 of the entries // Create a set of the oldest 1/3 of the entries
HashSet<QueryEntry> oldestSet = HashSet<QueryEntry> oldestSet =
......
...@@ -84,8 +84,7 @@ public class TestIntPerfectHash extends TestBase { ...@@ -84,8 +84,7 @@ public class TestIntPerfectHash extends TestBase {
while (set.size() < size) { while (set.size() < size) {
set.add(r.nextInt()); set.add(r.nextInt());
} }
ArrayList<Integer> list = new ArrayList<>(); ArrayList<Integer> list = new ArrayList<>(set);
list.addAll(set);
byte[] desc = IntPerfectHash.generate(list); byte[] desc = IntPerfectHash.generate(list);
int max = test(desc, set); int max = test(desc, set);
assertEquals(size - 1, max); assertEquals(size - 1, max);
......
...@@ -330,8 +330,7 @@ public class MinimalPerfectHash<K> { ...@@ -330,8 +330,7 @@ public class MinimalPerfectHash<K> {
* @return the hash function description * @return the hash function description
*/ */
public static <K> byte[] generate(Set<K> set, UniversalHash<K> hash) { public static <K> byte[] generate(Set<K> set, UniversalHash<K> hash) {
ArrayList<K> list = new ArrayList<>(); ArrayList<K> list = new ArrayList<>(set);
list.addAll(set);
ByteArrayOutputStream out = new ByteArrayOutputStream(); ByteArrayOutputStream out = new ByteArrayOutputStream();
int seed = RANDOM.nextInt(); int seed = RANDOM.nextInt();
out.write(seed >>> 24); out.write(seed >>> 24);
......
...@@ -246,8 +246,7 @@ public class ClassReader { ...@@ -246,8 +246,7 @@ public class ClassReader {
Token c = stack.pop(); Token c = stack.pop();
Stack<Token> currentStack = new Stack<>(); Stack<Token> currentStack = new Stack<>();
currentStack.addAll(stack); currentStack.addAll(stack);
ArrayList<Token> currentVariables = new ArrayList<>(); ArrayList<Token> currentVariables = new ArrayList<>(variables);
currentVariables.addAll(variables);
int branch = nextPc; int branch = nextPc;
Token a = getResult(); Token a = getResult();
stack = currentStack; stack = currentStack;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论