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

Use new ArrayList(Collection)

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