未验证 提交 b431eb42 编写于 作者: O Oleg Nenashev 提交者: GitHub

Merge pull request #3155 from Jimilian/cache_permission_id

Cache permission id to avoid allocating of new strings
......@@ -68,6 +68,9 @@ public final class Permission {
public final @Nonnull PermissionGroup group;
// if some plugin serialized old version of this class using XStream, `id` can be null
private final @CheckForNull String id;
/**
* Human readable ID of the permission.
*
......@@ -158,6 +161,7 @@ public final class Permission {
this.impliedBy = impliedBy;
this.enabled = enable;
this.scopes = ImmutableSet.copyOf(scopes);
this.id = owner.getName() + '.' + name;
group.add(this);
ALL.add(this);
......@@ -222,7 +226,10 @@ public final class Permission {
* @see #fromId(String)
*/
public @Nonnull String getId() {
return owner.getName()+'.'+name;
if (id == null) {
return owner.getName() + '.' + name;
}
return id;
}
@Override public boolean equals(Object o) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册