提交 aac42d22 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Use result of Collection.toArray(T[])

上级 606eebb5
...@@ -445,9 +445,7 @@ public class ConnectionInfo implements Cloneable { ...@@ -445,9 +445,7 @@ public class ConnectionInfo implements Cloneable {
* @return the property keys * @return the property keys
*/ */
String[] getKeys() { String[] getKeys() {
String[] keys = new String[prop.size()]; return prop.keySet().toArray(new String[prop.size()]);
prop.keySet().toArray(keys);
return keys;
} }
/** /**
......
...@@ -1234,8 +1234,7 @@ public class Database implements DataHandler { ...@@ -1234,8 +1234,7 @@ public class Database implements DataHandler {
} }
private synchronized void closeAllSessionsException(Session except) { private synchronized void closeAllSessionsException(Session except) {
Session[] all = new Session[userSessions.size()]; Session[] all = userSessions.toArray(new Session[userSessions.size()]);
userSessions.toArray(all);
for (Session s : all) { for (Session s : all) {
if (s != except) { if (s != except) {
try { try {
......
...@@ -352,9 +352,7 @@ public class Session extends SessionWithState { ...@@ -352,9 +352,7 @@ public class Session extends SessionWithState {
if (variables == null) { if (variables == null) {
return new String[0]; return new String[0];
} }
String[] list = new String[variables.size()]; return variables.keySet().toArray(new String[variables.size()]);
variables.keySet().toArray(list);
return list;
} }
/** /**
...@@ -835,8 +833,7 @@ public class Session extends SessionWithState { ...@@ -835,8 +833,7 @@ public class Session extends SessionWithState {
} }
} }
if (savepoints != null) { if (savepoints != null) {
String[] names = new String[savepoints.size()]; String[] names = savepoints.keySet().toArray(new String[savepoints.size()]);
savepoints.keySet().toArray(names);
for (String name : names) { for (String name : names) {
Savepoint sp = savepoints.get(name); Savepoint sp = savepoints.get(name);
int savepointIndex = sp.logIndex; int savepointIndex = sp.logIndex;
......
...@@ -155,8 +155,7 @@ public class IndexCondition { ...@@ -155,8 +155,7 @@ public class IndexCondition {
v = column.convert(v); v = column.convert(v);
valueSet.add(v); valueSet.add(v);
} }
Value[] array = new Value[valueSet.size()]; Value[] array = valueSet.toArray(new Value[valueSet.size()]);
valueSet.toArray(array);
final CompareMode mode = session.getDatabase().getCompareMode(); final CompareMode mode = session.getDatabase().getCompareMode();
Arrays.sort(array, new Comparator<Value>() { Arrays.sort(array, new Comparator<Value>() {
@Override @Override
......
...@@ -81,8 +81,7 @@ public class SpellChecker { ...@@ -81,8 +81,7 @@ public class SpellChecker {
// System.out.println(unused); // System.out.println(unused);
if (printDictionary) { if (printDictionary) {
System.out.println("USED WORDS"); System.out.println("USED WORDS");
String[] list = new String[used.size()]; String[] list = used.toArray(new String[used.size()]);
used.toArray(list);
Arrays.sort(list); Arrays.sort(list);
StringBuilder buff = new StringBuilder(); StringBuilder buff = new StringBuilder();
for (String s : list) { for (String s : list) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论