We should not create additional Strings in loop. It have perfomance impact. Using StringBuilder instead.

This commit is contained in:
vraskulin 2017-02-13 15:03:23 +03:00
parent 7f866f1b21
commit 5e410df39e

View file

@ -58,17 +58,17 @@ public class MagePreferences {
}
public static String getUserNames() {
String userIds = "";
StringBuilder userIds = new StringBuilder();
try {
String[] keys = prefs().keys();
for (String key : keys) {
if (key.matches(".*userName$")) {
userIds += "," + prefs().get(key, null);
userIds.append(',').append(prefs().get(key, null));
}
}
} catch (BackingStoreException ex) {
}
return userIds;
return userIds.toString();
}
public static void setUserName(String serverAddress, String userName) {