Cache the set made in ApplicableRegionSet.

This commit is contained in:
sk89q 2014-08-18 11:04:36 -07:00
parent 1a781fc5b0
commit bb1826bdb1

View File

@ -57,6 +57,8 @@ public class ApplicableRegionSet implements Iterable<ProtectedRegion> {
private final List<ProtectedRegion> applicable;
private final FlagValueCalculator flagValueCalculator;
@Nullable
private Set<ProtectedRegion> regionSet;
/**
* Construct the object.
@ -345,7 +347,11 @@ public int size() {
* @return a set of regions
*/
public Set<ProtectedRegion> getRegions() {
return new HashSet<ProtectedRegion>(applicable);
if (regionSet != null) {
return regionSet;
}
regionSet = Collections.unmodifiableSet(new HashSet<ProtectedRegion>(applicable));
return regionSet;
}
@Override