Minor performance improvements.

This commit is contained in:
Matt 2016-03-07 15:28:59 -05:00
parent d2c81cbd01
commit 286e5b8b97
2 changed files with 18 additions and 26 deletions

View File

@ -87,7 +87,7 @@ public class Visit extends SubCommand {
} else { } else {
final Plot plot = MainUtil.getPlotFromString(player, args[0], true); final Plot plot = MainUtil.getPlotFromString(player, args[0], true);
if (plot != null) { if (plot != null) {
unsorted = new HashSet<>(Collections.singletonList(plot.getBasePlot(false))); unsorted = Collections.singletonList(plot.getBasePlot(false));
} }
} }
break; break;

View File

@ -784,25 +784,21 @@ public class SQLManager implements AbstractDB {
stmt.setNull((i * 10) + 4, 4); // custom_time stmt.setNull((i * 10) + 4, 4); // custom_time
stmt.setNull((i * 10) + 5, 4); // time stmt.setNull((i * 10) + 5, 4); // time
stmt.setNull((i * 10) + 6, 4); // deny_entry stmt.setNull((i * 10) + 6, 4); // deny_entry
if (pair.settings.getAlias().equals("")) { if (pair.settings.getAlias().isEmpty()) {
stmt.setNull((i * 10) + 7, 4); stmt.setNull((i * 10) + 7, 4);
} else { } else {
stmt.setString((i * 10) + 7, pair.settings.getAlias()); stmt.setString((i * 10) + 7, pair.settings.getAlias());
} }
if (pair.settings.flags == null) { final StringBuilder flag_string = new StringBuilder();
stmt.setNull((i * 10) + 8, 4); int k = 0;
} else { for (final Flag flag : pair.settings.flags.values()) {
final StringBuilder flag_string = new StringBuilder(); if (k != 0) {
int k = 0; flag_string.append(",");
for (final Flag flag : pair.settings.flags.values()) {
if (k != 0) {
flag_string.append(",");
}
flag_string.append(flag.getKey() + ":" + flag.getValueString().replaceAll(":", "\u00AF").replaceAll(",", "\u00B4"));
k++;
} }
stmt.setString((i * 10) + 8, flag_string.toString()); flag_string.append(flag.getKey() + ":" + flag.getValueString().replaceAll(":", "\u00AF").replaceAll(",", "\u00B4"));
k++;
} }
stmt.setString((i * 10) + 8, flag_string.toString());
final boolean[] merged = pair.settings.getMerged(); final boolean[] merged = pair.settings.getMerged();
int hash = MainUtil.hash(merged); int hash = MainUtil.hash(merged);
stmt.setInt((i * 10) + 9, hash); stmt.setInt((i * 10) + 9, hash);
@ -829,20 +825,16 @@ public class SQLManager implements AbstractDB {
} else { } else {
stmt.setString((i * 10) + 7, pair.settings.getAlias()); stmt.setString((i * 10) + 7, pair.settings.getAlias());
} }
if (pair.settings.flags == null) { final StringBuilder flag_string = new StringBuilder();
stmt.setNull((i * 10) + 8, 4); int k = 0;
} else { for (final Flag flag : pair.settings.flags.values()) {
final StringBuilder flag_string = new StringBuilder(); if (k != 0) {
int k = 0; flag_string.append(",");
for (final Flag flag : pair.settings.flags.values()) {
if (k != 0) {
flag_string.append(",");
}
flag_string.append(flag.getKey() + ":" + flag.getValueString().replaceAll(":", "\u00AF").replaceAll(",", "\u00B4"));
k++;
} }
stmt.setString((i * 10) + 8, flag_string.toString()); flag_string.append(flag.getKey() + ":" + flag.getValueString().replaceAll(":", "\u00AF").replaceAll(",", "\u00B4"));
k++;
} }
stmt.setString((i * 10) + 8, flag_string.toString());
final boolean[] merged = pair.settings.getMerged(); final boolean[] merged = pair.settings.getMerged();
int n = 0; int n = 0;
for (int j = 0; j < 4; ++j) { for (int j = 0; j < 4; ++j) {