Remove unnecessary FlagValueCalculator#getPriority(ProtectedRegion) calls

This commit is contained in:
stonar96 2021-05-04 18:55:05 +02:00 committed by wizjany
parent 65c894cfe9
commit c1c26360e3

View File

@ -114,11 +114,13 @@ public Result getMembership(RegionAssociable subject) {
Set<ProtectedRegion> ignoredRegions = Sets.newHashSet();
for (ProtectedRegion region : getApplicable()) {
int priority = getPriority(region);
// Don't consider lower priorities below minimumPriority
// (which starts at Integer.MIN_VALUE). A region that "counts"
// (has the flag set OR has members) will raise minimumPriority
// to its own priority.
if (getPriority(region) < minimumPriority) {
if (priority < minimumPriority) {
break;
}
@ -131,7 +133,7 @@ public Result getMembership(RegionAssociable subject) {
continue;
}
minimumPriority = getPriority(region);
minimumPriority = priority;
boolean member = RegionGroup.MEMBERS.contains(subject.getAssociation(Collections.singletonList(region)));
@ -256,7 +258,9 @@ public <V, K> V queryMapValue(@Nullable RegionAssociable subject, MapFlag<K, V>
Set<ProtectedRegion> ignoredParents = new HashSet<>();
for(ProtectedRegion region : getApplicable()) {
if (getPriority(region) < minimumPriority) {
int priority = getPriority(region);
if (priority < minimumPriority) {
break;
}
@ -267,12 +271,12 @@ public <V, K> V queryMapValue(@Nullable RegionAssociable subject, MapFlag<K, V>
V effectiveValue = getEffectiveMapValue(region, flag, key, subject);
if (effectiveValue != null) {
minimumPriority = getPriority(region);
minimumPriority = priority;
consideredValues.put(region, effectiveValue);
} else if (fallback != null) {
effectiveValue = getEffectiveFlag(region, fallback, subject);
if (effectiveValue != null) {
minimumPriority = getPriority(region);
minimumPriority = priority;
fallbackValues.put(region, effectiveValue);
}
}
@ -389,7 +393,9 @@ private <V> Collection<V> queryAllValues(@Nullable RegionAssociable subject, Fla
Set<ProtectedRegion> ignoredParents = new HashSet<>();
for (ProtectedRegion region : getApplicable()) {
if (getPriority(region) < minimumPriority) {
int priority = getPriority(region);
if (priority < minimumPriority) {
break;
}
@ -398,7 +404,6 @@ private <V> Collection<V> queryAllValues(@Nullable RegionAssociable subject, Fla
}
V value = getEffectiveFlag(region, flag, subject);
int priority = getPriority(region);
if (value != null) {
minimumPriority = priority;
@ -416,7 +421,7 @@ private <V> Collection<V> queryAllValues(@Nullable RegionAssociable subject, Fla
// PASSTHROUGH is not set to ALLOW
if (priority != minimumPriority && flag.implicitlySetWithMembership()
&& getEffectiveFlag(region, Flags.PASSTHROUGH, subject) != State.ALLOW) {
minimumPriority = getPriority(region);
minimumPriority = priority;
}
}