mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-11-08 20:09:59 +01:00
Convert permissions to lowercase inside the cache
Slight optimization, toLowerCase is a relatively expensive call in the scheme of permission checks.
This commit is contained in:
parent
c19ef84116
commit
1544487e92
@ -47,6 +47,8 @@ import java.util.Optional;
|
|||||||
* <li>{@code org.bukkit.entity.Player}</li>
|
* <li>{@code org.bukkit.entity.Player}</li>
|
||||||
* <li>{@code net.md_5.bungee.api.connection.ProxiedPlayer}</li>
|
* <li>{@code net.md_5.bungee.api.connection.ProxiedPlayer}</li>
|
||||||
* <li>{@code org.spongepowered.api.service.permission.Subject}</li>
|
* <li>{@code org.spongepowered.api.service.permission.Subject}</li>
|
||||||
|
* <li>{@code cn.nukkit.Player}</li>
|
||||||
|
* <li>{@code com.velocitypowered.api.proxy.Player}</li>
|
||||||
* </ul>
|
* </ul>
|
||||||
*
|
*
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
|
@ -81,10 +81,6 @@ public class PermissionCalculator implements Function<String, Tristate> {
|
|||||||
* @return the result
|
* @return the result
|
||||||
*/
|
*/
|
||||||
public Tristate getPermissionValue(String permission, PermissionCheckEvent.Origin origin) {
|
public Tristate getPermissionValue(String permission, PermissionCheckEvent.Origin origin) {
|
||||||
// convert the permission to lowercase, as all values in the backing map are also lowercase.
|
|
||||||
// this allows fast case insensitive lookups
|
|
||||||
permission = permission.toLowerCase();
|
|
||||||
|
|
||||||
// get the result
|
// get the result
|
||||||
Tristate result = this.lookupCache.get(permission);
|
Tristate result = this.lookupCache.get(permission);
|
||||||
|
|
||||||
@ -97,6 +93,10 @@ public class PermissionCalculator implements Function<String, Tristate> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Tristate apply(@NonNull String permission) {
|
public Tristate apply(@NonNull String permission) {
|
||||||
|
// convert the permission to lowercase, as all values in the backing map are also lowercase.
|
||||||
|
// this allows fast case insensitive lookups
|
||||||
|
permission = permission.toLowerCase();
|
||||||
|
|
||||||
// offer the permission to the permission vault
|
// offer the permission to the permission vault
|
||||||
// we only need to do this once per permission, so it doesn't matter
|
// we only need to do this once per permission, so it doesn't matter
|
||||||
// that this call is behind the cache.
|
// that this call is behind the cache.
|
||||||
|
Loading…
Reference in New Issue
Block a user