mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 13:16:45 +01:00
Refactoring of PS#getPlots:
Initialize to HashSet rather than ArrayList, because of add in HashSet is O(1) vs. add in ArrayList which is O(n). Also make the wrapping set immutable.
This commit is contained in:
parent
032484b0f5
commit
16dbbe5244
@ -966,18 +966,16 @@ public class PS {
|
||||
*
|
||||
* @param area the {@code PlotArea}
|
||||
* @param uuid the plot owner
|
||||
* @return Set of plot
|
||||
* @return Set of plots
|
||||
*/
|
||||
public Set<Plot> getPlots(PlotArea area, UUID uuid) {
|
||||
ArrayList<Plot> myplots = new ArrayList<>();
|
||||
final HashSet<Plot> plots = new HashSet<>();
|
||||
for (Plot plot : getPlots(area)) {
|
||||
if (plot.hasOwner()) {
|
||||
if (plot.isOwnerAbs(uuid)) {
|
||||
myplots.add(plot);
|
||||
if (plot.hasOwner() && plot.isOwnerAbs(uuid)) {
|
||||
plots.add(plot);
|
||||
}
|
||||
}
|
||||
}
|
||||
return new HashSet<>(myplots);
|
||||
return Collections.unmodifiableSet(plots);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user