Reduce the throughput on the contexts cache in ContextManager (#929)

This commit is contained in:
Luck
2018-05-12 01:34:34 +01:00
Unverified
parent 804c884d8b
commit a927ca659f
8 changed files with 245 additions and 85 deletions
@@ -26,6 +26,8 @@
package me.lucko.luckperms.sponge.service.proxy.api6;
import me.lucko.luckperms.api.context.ImmutableContextSet;
import me.lucko.luckperms.common.contexts.ContextManager;
import me.lucko.luckperms.common.contexts.ContextsCache;
import me.lucko.luckperms.common.utils.ImmutableCollectors;
import me.lucko.luckperms.sponge.service.CompatibilityUtil;
import me.lucko.luckperms.sponge.service.model.LPPermissionService;
@@ -52,9 +54,14 @@ public final class SubjectProxy implements Subject, ProxiedSubject {
private final LPPermissionService service;
private final LPSubjectReference ref;
private final ContextsCache<Subject> contextsCache;
public SubjectProxy(LPPermissionService service, LPSubjectReference ref) {
this.service = service;
this.ref = ref;
ContextManager<Subject> contextManager = (ContextManager<Subject>) service.getPlugin().getContextManager();
this.contextsCache = contextManager.getCacheFor(this);
}
private CompletableFuture<LPSubject> handle() {
@@ -157,7 +164,7 @@ public final class SubjectProxy implements Subject, ProxiedSubject {
@Nonnull
@Override
public Set<Context> getActiveContexts() {
return CompatibilityUtil.convertContexts(this.service.getContextManager().getApplicableContext(this));
return CompatibilityUtil.convertContexts(this.contextsCache.getContextSet());
}
@Override