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 area the {@code PlotArea}
|
||||||
* @param uuid the plot owner
|
* @param uuid the plot owner
|
||||||
* @return Set of plot
|
* @return Set of plots
|
||||||
*/
|
*/
|
||||||
public Set<Plot> getPlots(PlotArea area, UUID uuid) {
|
public Set<Plot> getPlots(PlotArea area, UUID uuid) {
|
||||||
ArrayList<Plot> myplots = new ArrayList<>();
|
final HashSet<Plot> plots = new HashSet<>();
|
||||||
for (Plot plot : getPlots(area)) {
|
for (Plot plot : getPlots(area)) {
|
||||||
if (plot.hasOwner()) {
|
if (plot.hasOwner() && plot.isOwnerAbs(uuid)) {
|
||||||
if (plot.isOwnerAbs(uuid)) {
|
plots.add(plot);
|
||||||
myplots.add(plot);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
return Collections.unmodifiableSet(plots);
|
||||||
return new HashSet<>(myplots);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user